Prevent Object/Character from "drifting" away from Collider

Hey folks!

I am currently working on a 2D MMO RPG!

And I am sort of running into a little “problem”…

Here’s the thing: I have a gameobject (the Player) who is moved using the transform.Translate function, everything works fine and all, but if a player runs against a collider which stops the player from moving (a simple box collider) the collider also creates velocity so that the player starts to “drift” away from the colliderbox…
Now I do use Sleep() and WakeUp() when the player lets go of all the movement buttons, so the player stands still again, which works fine, but it doesn’t solve the problem if the player keeps holding a movement key after running against a wall (which can make a player significantly faster…)

If you need any exact codelines, just tell me, and I shall add them!


I know this thread is old, but I fixed it on my own:

I had no Gravity/Drag enabled on my rigidbody (because the game’s only 2D) but with the gravity and drag/angular drag enabled and set to a moderate amount, everything works and the character is not getting pushed away from walls anymore!