Gravity in XNA pt.2

For discussions about game development that does not fit in any of the other topics.
Post Reply
Xaleph
Posts: 897
Joined: Mon Feb 07, 2011 2:55 am

Gravity in XNA pt.2

Post 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?
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: Gravity in XNA pt.2

Post 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/
Fighting for peace is declaring war on war. If you want peace be peaceful.
Post Reply

Return to “General Development”