Advertisement Jump to content
Sign in to follow this  

2D scroll game gravity problem with "slide" and "update after collision" procedure

This topic is 1271 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



I am almost finished with my 2D engine that supports polygons with all angles.

the way i do collision detection is:



update() //pushed the players out again if there was some penetration that was not permitted (this is done recursivly with the smallest TOI first)


everything works great, BUT


one small thing is if my player is standing on a very small hill, he continues to slide very very small distance in the x-axis.


this is becuase the gravity vector is always added and the the player is being pushed down, and with the corrections it is resulting with a movement..


The way i slide is this:

                var dotN =;
                game.player.vVel.x -= (current_pushvector.x * dotN);
                game.player.vVel.y -= (current_pushvector.y * dotN);


But this is wrong for 2D scrollers i think.


What kind of collision response do you do on 2D scrollers?





Share this post

Link to post
Share on other sites
Thanks alot.

Didnt think the last 5% should be so tricky, but it is lots of trimming to get the jump and friction plus slide to work and create a good gameplay.

Excellent links, thank you very much.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!