var h = Input.GetAxisRaw("Horizontal");
if (h == 0)
{
_rigidBody.velocity = new Vector2(0, 0);
}
My expectation that when i dont press “A” or “D” _rigidBody just stay on one point. But it works only on flat ground. When i have hill, rigidbody is sliding down
I see you have no Physics Material Specified for your Character. Create a new one, and give it a high friction value, then assign it to the character’s rigidbody. (Friction is what keeps stuff from sliding down hills in real life too.) Keep in mind, you may want to also assign a material to the hill also!
Numbers-wise(for some reason not mentioned on that help page): a friction of near ZERO, is slippery, like ice. a friction near ONE is a good solid contact like rubber tires on a road.
I’ve seen some solutions in which people do the following: when the player is moving, change the physics material friction to 0. When the player stop moving, change the material friction to some high number (you need to test it out, probably 50 will do, if it doesn’t, go higher). This way you can walk normally and when you stop the player doesn’t move due physics.