This project has moved and is read-only. For the latest updates, please go here.

AABB.Intersect unclear result in update

Oct 6, 2008 at 2:46 PM

Im using this code in my update method:



(UGField field in undergroundFields)
        if (AABB.Intersect(pod.Geom.AABB, field.Geom.AABB))

which determines whether my "pod" i standing on a block/field of dirt, a square body. But when it stands on the block/field it sometimes (many times since the update method runs all the time) returns false, telling that my pod AABB does not intersect with the fields AABB, why? i can't see my pod jumping or bouncing on the field. Is there something i missed?


Oct 6, 2008 at 3:12 PM
When 2 objects are standing on each other, they are jittering a little. They are constantly calculating collisions and impulses, so that might be your problem.

Since the AABB's of your pod and the ground are the size each of them, only a single pixel difference is needed to make them not touch.
You could create a larger AABB around your pod and use that instead.

You could also work around it by creating some tolerance. The jittering should only cause the pod to not intersect in a single update. So (1 update = false and 1 update = true) == true, if that makes sense.
Oct 6, 2008 at 3:24 PM
how can i increase the AABB with 1 or 2 pixels around my pod?
Oct 6, 2008 at 3:37 PM
You should not increase the current AABB (you can't do it) since it's used in the broad phase collision detection. You should make a new one that surrounds the pod.
Like from your other thread here:

Update: It seems that SomethingNew (a user) also want's to increase the size of the AABB a little, I will consider putting it into my TODO list.
Oct 6, 2008 at 10:58 PM
@Arextion - increasing the AABB of your Geom will only give the narrow phase more time to detect collisions. I think maybe you should use a sampling method and decide when the objects are touching by averaging the your above code over a few frames. That would help with any jittering you have.
Oct 7, 2008 at 9:03 AM
Thx for the help, i used this simple method to solve the problem:



(podIntersectList.Count == 0)













if (hoverList.Count >= 3)




if (hoverList[0] || hoverList[1] || hoverList[2])


pod.isFlying =






pod.isFlying =





Oct 7, 2008 at 4:01 PM
@Arextion - that's exactly what I meant. Glad it worked for you.