# Game Physics: Implementing Normal Reaction from ground correctly

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 ?

• Can't say I know the right answer, but I've heard that most people will take the character and cast a ray downward into the terrain to detect if the player is on top or near enough and then set the players height to match the terrain. But again I just heard that and never implemented it (that is why this is a comment and not an answer) Commented Oct 29, 2012 at 16:51