Game Physics: Implementing Normal Reaction from ground correctly
- by viraj
I am implementing a simple side scrolling platform game. I am using the following strategy while coding the physics:
Gravity constantly acts on the character.
When the character is touching the floor, a normal reaction is exerted by the floor.
I face the following problem:
If the character is initially at a height, he acquires velocity in the -Y direction. Thus, when he hits the floor, he falls through even though normal force is being exerted. I could fix this by setting the Y velocity to 0, and placing him above the floor if he has collided with it. But this often leads to the character getting stuck in the floor or bouncing around it. Is there a better approach ?