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

This topic is 3629 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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: 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 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 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 on other sites
Awesome that works perfectly. Thanks heaps!

cheers,
metal

##### Share on other sites
I'd use this solution.

1. 1
Rutin
26
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 21
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631763
• Total Posts
3002187
×