Jump to content
  • Advertisement
Sign in to follow this  
Kurt-olsson

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

This topic is 1179 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

Hi!

 

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

the way i do collision detection is:

 

move();

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 = current_pushvector.dot(game.player.vVel);
                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
Advertisement
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 GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!