Question by
phonoks · Dec 30, 2016 at 12:45 AM ·
movementcharactercontrollerturningfacing
Face player to movement while not turning character controller
So my problem is when i turn my player in the face of movement my character controller also turns. I dont want this to happen because my camera is going to be stable. So if my character controller turns with the player my controlls just get messed up because my camera is fixed. So can anyone help me in this matter? I have checked all answers about this issue(which are very few) but couldnt solve my problem. Thanks!
public float speed = 6.0F;
public float jumpSpeed = 8.0F;
public float gravity = 20.0F;
private Vector3 moveDirection = Vector3.zero;
void FixedUpdate() {
CharacterController controller = GetComponent<CharacterController>();
moveDirection = new Vector3(CrossPlatformInputManager.GetAxis("Horizontal"), 0, CrossPlatformInputManager.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
//moveDirection.y = jumpSpeed;
moveDirection.y -= gravity * Time.deltaTime;
controller.Move (moveDirection * Time.deltaTime);
Comment
$$anonymous$$aybe adding World.Space should work? but where should i put that i tried it but no code here accepts it