Movement speed doubled when moving diagonally

Hey everyone,

I have been having a problem with movement of a sphere; the speed is doubled when moving in a diagonal direction (WASD). I have read up on this and the issues stems from the force being applied twice when the 2 directions are pressed, ie. W +D.

The information I have come across suggests using .Normailze.
However I have added this to my code and there has been no resolution. Could anybody give me any advice?

 public float maxSpeed = 5f;
 public float Speed;
 private Rigidbody rb;

 void Start ()
    spawn = transform.position;
    rb = GetComponent<Rigidbody>();

Vector3 direction = new Vector3(0, 0, 0);

    float moveHorizontal = Input.GetAxis("Horizontal");
    float moveVertical = Input.GetAxis("Vertical");

    Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);

if (rb.velocity.magnitude < maxSpeed)
            rb.AddForce(movement * Speed);

Thanks for Reading, any help would be appreciated

It looks like you’re normalizing a vector that you’re not even using (direction). You probably want to normalize your movement vector.

So, instead of:


You want:


I’m not even sure why you have the direction vector (unless you’re using it in unposted code).