Hey lads, I was curious why my character behaves differently depending on whether I use keyboard or controller.
So I’m using GetAxisRaw which gets either -1, 0, 1, right, no in between.
If I use the d-pad on the controller, the character is snappy and instantly switches angles, like pure 8 directional movement.
If I use the keyboard though, W, A, S, D it’s almost as if it lerps the movement, it rotates over time, not instantly. But both use the same code, why is that?
Code for reference;
void PlayerDirection()
{
if (Input.GetAxisRaw("Horizontal") != 0 || Input.GetAxisRaw("Vertical") != 0)
{
angle = Mathf.Atan2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")) * Mathf.Rad2Deg;
}
transform.eulerAngles = new Vector3(0, angle, 0);
}
void PlayerLocomotion()
{
Vector3 movement = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
gameObject.GetComponent<Rigidbody>().velocity = movement.normalized * speed * Time.deltaTime;
}