Can I simulate collision by bounding box?

Here is a scene with a box and two planes, I want to move the box without rigidbody and collision component, and I need to stop the box when it “collision” the plane, so that the box can not pass through any plane. Can I simulate this by bounding box?

You will need to make box / plane collision checks yourself. There should be plenty of resources online to check out how that can be done. Once you find out what the Math is you can then check if the box collides or intersects any of your planes and move it to the right position.

Also if you are only moving the box on a single plane like only horizontally and not vertically you can reduce the problem to just 2D rectangle / plane checks instead of dealing with 3D.

I did some research after your reply. The basic idea is to calculate the distance of two bounding box’s center. This is easy in 2D.

Here is my scene, you can see the “walls” are rotated, and their aabb are become large than their size. In this case, calculating the distance of the box’s aabb and the walls’ aabb maybe wrong.

What I want is to move the box on the floor at first, and when it “collide” the wall, it can move on the plane.

The AABB is useful for broad-phase checks. This means that it’s good for detecting if two objects have the potential to collide. But if you do an AABB test you then need to make an accurate test to see if your objects actually collide.

If you rotate the wall like you show in your image the AABB becomes very large because it tries to encompass the entire plane. Thus the collision test will not be accurate. In your case, specifically if you only have a few walls and boxes to test you don’t really need to do an AABB test at all. Just do box-plane collision tests.

Another way to do this if you’re only doing 2D physics, is to use a simpler physics library like p2.js ( We have an example project on how to integrate p2 in your project here .

How can I do this test? Any examples?

I think Google will be your friend here. Also this book has every possible test I’ve ever needed .

To be honest though even simple physics are tricky to make them work right. My suggestion would be to use p2.js.

1 Like