Sign in to follow this  
metalmidget

[RESOLVED]AABB vs AABB- Found the problem, not sure how to fix it

Recommended Posts

So far all my objects are AABBs- I'm in a fairly early stage. The dude in my platformer keeps kinda getting stuck on the edges of tiles, but only when he's moving really slowly, and his left edge is only just hanging over the left edge of the tile he's standing on. After much debugging, I'm almost certain I've figured out why: annoying problem In that picture, gravity is pulling the player downwards into the tiles, and the player is moving very slowly either to the left or right. Collision between the player and tile 1 happens first. In my collision system, the player is moved out of a tile in either the x or the y direction- I find the required distance in each axis(dx and dy) and choose the smaller one (ie- find the MTD) to move the player by. The problem here is that dx is smaller than dy, so the player is moved to the right, rather than up. The consequence of that is that the player's horizontal speed is then set to zero, which makes the player stop when he shouldn't. I'm not sure what I should change to remedy this. cheers, metal PS- Because these particular tiles were created in order from left to right, it's only the situation above that causes the problem. If I were to iterate over the tiles in reverse order, the problem would only happen when the right edge of the player was slightly over the right edge of the tile he's standing on. (That's my theory anyway, haven't actually tested it) [Edited by - metalmidget on August 12, 2008 6:33:03 AM]

Share this post


Link to post
Share on other sites
Can't you set the gravity to 0 when your player is standing on the ground, and set it back to normal when he has jumped or fell off from a platform?

Share this post


Link to post
Share on other sites
Good idea, I'll try that now. I'm already implementing friction on all objects with a platform directly beneath them, so I'll just move the gravity into that section as well.
brb

cheers,
metal

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this