Download

How to detect when an object is enclosed

My game allows you to place geometry to build structures of an arbitrary shape. I’m puzzling about the best methodology for figuring out if the structure is ‘watertight’. It would be useful to know this so that interiors could be ‘heated’, filled with O2, etc.

Possible Solutions:

3D A* from center of structure to see if there’s a way out (potentially expensive, and somewhat complex to implement since it’s not currently supported by UE4 out of the box)

Check edges of each structural component to see if it has neighbors (there are quite a few edge cases where this could break down)

Use traces to figure out if the player can ‘see’ out of the structure and set player state to interior/exterior accordingly (a bit hacky, and easy to abuse)