Sphere collision checking is probably the easiest way to provide 3D collision checking in 3D games. To find if two objects are colliding all you have to do is calculate the distances of the two objects geometric origins and check whether it's lesser than the sum of the two objects radii. If it is, then the objects intersect, they have already collided. If it's the same, then they are colliding. And if not, they haven't collided.

pseudocode to calculate distance: xd = x2-x1; yd = y2-y1; zd = z2-z1; Distance = SquareRoot(xd*xd + yd*yd + zd*zd);

x1,x2, y1,y2, z1,z2 are the 3D coordinates of the two objects.

pseudocode to calculate distance avoiding square root. Needs to be written, see between two points at Hugo Elias TGLTLSBFSSP

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.