Hi, I have a third person character controller that works very much like Lerpz, the problem is that when I stop giving input the rotation gos back to zero.
Here’s the script:
private var moveDirection = Vector3.zero;
private var grounded : boolean = false;
var speed = 6.0;
var gravity = 20.0;
var doesRotate = false;
function Update () {
// move x or z relative to the camera
if (grounded) {
moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
moveDirection = Camera.main.transform.TransformDirection(moveDirection);
moveDirection *= speed;
if (doesRotate) {
transform.rotation = Quaternion.LookRotation(moveDirection);
}
}
// Apply gravity
moveDirection.y -= gravity * Time.deltaTime;
var controller : CharacterController = GetComponent(CharacterController);
var flags = controller.Move(moveDirection * Time.deltaTime);
grounded = (flags CollisionFlags.CollidedBelow) != 0;
}
Does anyone know what the problem is?