I'm making a topdown 2D RPG in Unity. All moveable objects have Rigidbody2D-components with gravity set to 0, linear drag set to 5 and different masses. Walls are stationary boxes with BoxCollider2Ds.
Here's my problem: http://a.pomf.se/nifmcn.webm The rock is not particularly easy to see, but if you watch when I'm trying to walk into a wall, the player kind of jags in and out of the wall.
Of course, this is because I'm moving the player by moving it's Rigidbody2D, for example:
rigidbody2D.transform.position += Vector3.up*Time.deltaTime*speed;
The box then throws the player in the opposite direction of what he was going.
What's a good way of stopping a player from moving in the direction he's trying to go? More specifically, how do you detect which way he's going? Do you find the angle between the player and the object/wall?
This is kind of an open question, but I think it's extremely important.