So I have the character looking at the mouse and he’ll rotate to face it. Now however, when I move my character, he doesn’t move the way I want him to. “W” is no longer upwards (North), “S” is no longer South, “A” is no longer West, and “E” is no longer East. It all depends on the direction the player is facing. So if he is facing left, West, and I hit “W”, he’ll move forward in the West direction, but I want “W” to always be north, “S” always be South, and so on. Here’s my movement code that I use with a character Controller.
var controller : CharacterController = GetComponent(CharacterController);
if (controller.isGrounded) {
var zaxis : float = Input.GetAxis ("Vertical") * (playerSpeed - (playerSpeed -1));
moveDirection = Vector3(Input.GetAxis("Horizontal"), 0,zaxis);
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= playerSpeed;
}
// Apply gravity
moveDirection.y -= gravity * Time.deltaTime;
// Move the controller
controller.Move(moveDirection * Time.deltaTime);
Any help would be appreciated and I’m sure it’s a simple fix. Thank you all in advance.