Page 1 of 1

Gravity in XNA pt.2

Posted: Sat Nov 05, 2011 5:07 pm
by Xaleph
Hi all, i`m back with another stupid question:

I finally managed to integrate gravity ( I finished level editors, game states, particles engines et cetera first) but now i`m back to the one thing I hate, physics.

Turns out gravity wasn`t THAT hard to finish ( still, it took my a while ) but now i`m going into collision detection. I`ve managed to apply gravity, it will fall down, but now the whole logic when jumping on tiles et cetera is catching up. The thing is, when I collide, i update the current Y axis to the player, but when i jump into a tile which is higher, i automatically get on top of it.. Kind of annoying, so if anyone is kind enough to help me out.. How do I apply physics in a game that works?

Re: Gravity in XNA pt.2

Posted: Sat Nov 05, 2011 6:25 pm
by Chris
Stop movement in the direction of the collision. One of the biggest problems when making collision detection is an object sometimes ends up getting stuck against another object because you have to disabled movement. I've written my own collision detection which causes objects to bounce off one another to prevent this but there are different methods.

http://www.gamespp.com/algorithms/collisiondetection/