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

Started by
1 comment, last by Kurt-olsson 8 years, 8 months ago

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?

Advertisement

There's no one answer: a lot depends on what kind of scroller/platformer you're making. But here are some links about getting the right feel:

http://blog.brendanvance.com/2012/04/22/the-quest-for-good-platformer-mechanics/

http://higherorderfun.com/blog/2012/05/20/the-guide-to-implementing-2d-platformers/

http://info.sonicretro.org/Sonic_Physics_Guide

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.

This topic is closed to new replies.

Advertisement