Hi, i'm new to unity and I i was trying to create an object that make the player jump, however i've some problem, when the player hit the collider (trigger) the function ontriggerenter is called, but the player don't jump. However if the player hit the trigger while jumping, he then jumps again.
enter code here function OnTriggerEnter( collisionInfo : Collider){
if(collisionInfo.gameObject.tag == "molla"){
muoviunity.moveDirection.y = 100;
}
}
This is the "event", and this is the function that moves the player:
var speed : float = 6.0;
var jumpSpeed : float = 8.0;
var gravity : float = 20.0;
static var moveDirection : Vector3 = Vector3.zero;
var speed : float = 6.0;
var jumpSpeed : float = 8.0;
var gravity : float = 20.0;
static var moveDirection : Vector3 = Vector3.zero;
function Update() {
var controller : CharacterController = GetComponent(CharacterController);
if (controller.isGrounded) {
// We are grounded, so recalculate
// move direction directly from axes
moveDirection = Vector3(Input.GetAxis("Horizontal"), 0,
Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
if (Input.GetButton ("Jump")) {
moveDirection.y = jumpSpeed;
}
}
// Apply gravity
moveDirection.y -= gravity * Time.deltaTime;
// Move the controller
controller.Move(moveDirection * Time.deltaTime);
}