Page 1 of 1

Bounding box, silly issues help please!

Posted: Thu Mar 05, 2009 10:51 pm
by boxrick
I have a game world, with all entities being contained by a bounding box. This is working fine, i am in the process of updating my collision code. However im having issues with deciding if objects are colliding am i doing this right? If not where am i going wrong?

I have object A and object B with x y and z max and minimums of them all.

1) (if object A min X >Object B max X OR object B min X >Object A max X)
X axis is colliding

(if object A min Y>Object B max Y OR object B min Y >Object A max Y)
Y axis is colliding

(if object A min Z >Object B max Z OR object B min Z >Object A max Z )
Z axis is colliding

if X / Y and Z axis are colliding then i have a collision

Posted: Thu Mar 05, 2009 11:14 pm
by Spike
don't you mean:
if (a.min_x <= b.max_x && a.max_x >= b.min_x &&
a.min_y <= b.max_y && a.max_y >= b.min_y &&
a.min_x <= b.max_z && a.max_z >= b.min_z)
collide();