the elevator is simple, collider that rises and falls, for an animation.
the problem is that when I go to the elevator, the * character controller * falls to move the elevator up.
How achieving the *. Character controller. * Up by elevators without falling?
this is the code with the problem:
#pragma strict
var x :int = 1;
var controller:CharacterController = null;
var rapides : float = 6.0;
var gravedad : float = 20.0;
var velocidadSalto : float = 8.0;
var corriendo = false;
var tiempo : float = 0.0;
private 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 *= rapides;
}
//
if(!(x<=0)&&Input.GetButtonDown("Jump")) {
//
moveDirection.y = velocidadSalto;
x--;
}
if(controller.isGrounded) {
x = 1;
}
//
if (Input.GetButtonDown("Run")) {
rapides = 9.0;
corriendo = true;
}
else if (Input.GetButtonUp("Run")) {
rapides = 6.0;
corriendo = false;
}
if(corriendo)
{
tiempo += Time.deltaTime;
}
if(tiempo >= 7)
{
corriendo = false;
rapides = 7;
tiempo = 0;
}
// Apply gravity
moveDirection.y -= gravedad * Time.deltaTime;
// Move the controller
controller.Move(moveDirection * Time.deltaTime);
}
///////////////////////////////////////////////////////////////////