After the player collides into an object, the player is unable to move through the object due to the collider (this is as expected). When the movement input (WASD or arrow keys) are NOT being pressed, the player begins moving in the opposite direction of what it collided with (sometimes fast, sometimes slow).
When it occurs, trying to move in the opposite direction it is traveling results in a “tug-of-war” between the human input and whatever is going on. Any other input (including colliding with another object) results in whatever is going on to stop.
I am assuming that something is causing the player to think it is being pushed on and a programmatic reset of this would resolve it. When I put GetComponent().velocity = new Vector3(0, 0, 0) inside the OnCollisionEnter method of the player, this behavior continued.
Why is this happening and how do I resolve it?
Movement is calculated using the following:
float
X = Input.GetAxis(“Horizontal”) * Time.deltaTime * MoveSpeed,
Y = 0.0f,
Z = Input.GetAxis(“Vertical”) * Time.deltaTime * MoveSpeed;
transform.Translate(X, Y, Z);
To resolve a different issue of the player passing through the collider, I have update the Default Max Depenetration Velocity (Edit > Project Settings > Physics) from 10 to 1000.
I am using Unity Version: 2020.3.22f1.1228 Personal