Advertisement

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

Started by May 28, 2018 04:42 PM
1 comment, last by Dirk Gregorius 6 years, 8 months 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!

 

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