Sign in to follow this  
Michael Lojkovic

Aabb gets stuck when moving between 2 aabb next to each other.

Recommended Posts

I'm testing 3d aabbs against each other. They're swept aabbs to prevent penetration of each other, and have center and halfwidth properties. During the sweep test I find the collision normal of the moving aabb to determine which face collided. Based off of the normal returned I push the collided aabb in the opposite direction.

The only issue I'm having is when two adjacent aabbs have collinear center vectors the player gets repelled on the x and y axis when only one should occur. (these are two separate collision tests between the player and each aabb.) To solve this I took the cross product of adjacent aabbs, and set them to ignore collisions when collinear. (my aabbs are sorted from lowest x value to highest.) This kind of works, but now aabbs like walls no longer collide, if they're collinear.

How could I go about ignoring collisions when aabbs are directly adjacent to each other, but still pass when representing walls?

Here's a pic of the 3 cases:

Share this post


Link to post
Share on other sites

Favorite solution: use another shape for the player, like a capsule. Alternatives: tune the swept collision resolution to factor in a "skin radius" to keep the player floating above the numeric inaccuracies between tiles. And finally if you know which two AABBs are adjacent to one another you can treat sides of them as if they were welded together, and handle the tiny gaps between them with some specialized code.

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