Hi everybody,
I’ve got a little problem.
Whenever my character moves position (like walking), the rotation works like it should.
But whenever the character tries to rotate whenever it isn’t moving, it spins out like crazy.
This also happens whenever it tries to walk backwards.
It seems that whenever it rotation while not moving, it turns 90 degrees (everytime the rotation is being called) and 180 degrees when trying to walk backwards.
I do have a character controller attached with the default settings and I’m using the following script.
public class ThirdPersonMoveScript : MonoBehaviour
{
public float walkSpeed = 3f;
public float runSpeed = 6f;
public float mouseSenitivity = 100f;
private Vector3 moveDirection = Vector3.zero;
void Update()
{
CharacterController controller = GetComponent<CharacterController>();
moveDirection = new Vector3(Input.GetAxis("Mouse X") * mouseSenitivity, 0, Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
if (Input.GetKey(KeyCode.LeftShift))
{
moveDirection *= runSpeed;
}
else
{
moveDirection *= walkSpeed;
}
if (moveDirection != Vector3.zero)
{
//transform.rotation = Quaternion.LookRotation(moveDirection);
controller.transform.rotation = Quaternion.LookRotation(moveDirection);
}
controller.Move(moveDirection * Time.deltaTime);
}
}
Is anyone familiar with this problem?
Thanks upfront,
Jenoah