Look at the picture.
The figure on the left shows the individual box colliders in green.
The yellow boxes on the right are the results of the optimization of the original box colliders.
What is the algorithm that makes this possible?
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.
Sign up to join this communityLook at the picture.
The figure on the left shows the individual box colliders in green.
The yellow boxes on the right are the results of the optimization of the original box colliders.
What is the algorithm that makes this possible?
Sure you can.
Assuming you have a list of BoxCollider
that need to be combined, you can access each of their bounds
properties, which consist of the boxes' center
and extents
. With this two information in mind, you can easily calculate the minimum and maximum x, y, and z coordinates of the boxes.
The combined BoxCollider
will have these two corners: and
. From upper and lower corners, you can calculate the center and extents of the combined
BoxCollider
.
All you need to do later is remove or disable initial BoxCollider
s in your list.