🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Is there a more optimized way to check collision on moving box vs static box? (AABB AABB)

Started by
1 comment, last by Dirk Gregorius 6 years, 1 month ago

I'm currently implementing a moving AABB vs static AABB collision with the velocity of the box, in a minecraft-like game.

Since the blocks in my game don't have any collider(for performance issue), this is what I do to check the collision.

with the velocity of the moving box, considering it as the direction vector(ray),  check if there is a box within the range of the velocity.

If the box is jumping, and moving on +x axis / - z axis.

 

raycasting.png.98a00a0d9b800502dce72886d15af610.png

I check all 6 edges with the vector to see if there is a collision.

But is there a more optimized way to check collision than this method?

Thank you!

 

Advertisement

You can just build the Minkowski sum of the two boxes and then raycast against this. E.g. add the half extents of the dynamic box to the static box and then raycast from the center of the dynamic box in the direction of the velocity time the timestep against the inflated box. 

This topic is closed to new replies.

Advertisement