[Help] Player stops moving when hitting wall diagonally
I am creating a top-down 2D game, but the physics aren't working correctly. When you hit a wall, it stops as intended, but if you try to move diagonally against the wall it stops you completely. I want the player to be able to slide against the wall by moving diagonally against it, and not act like he is glued to the wall. I am using 3D physics because of the way my game works, but everything else is 2D. Does anyone know how to fix this? This is the movement script I am using:
Vector3 movement;
void Update () { float xInput = PlayerSpeed Time.deltaTime Input.GetAxis ("Horizontal") / 2; float yInput = PlayerSpeed Time.deltaTime Input.GetAxis ("Vertical") / 2; movement = new Vector3 (xInput 100, yInput 100, 0); }
void FixedUpdate () { GetComponent ().AddForce(movement); }
Thanks in advance!