Hi,
While procedurally generating a dungeon I need to check that a newly placed room doesn’t overlap with any of the old ones.
For performance reasons I can’t actually place the rooms in the scene so I keep a simple room structure in memory containing pretty much only the collider info for the room and its exits.
For square/cube rooms collider.bounds.Intersects method works fine, but for other shapes (hexagonal, circular etc) AABB won’t quite cut it.
How can I check for overlaps between colliders?
Thanks!
Collision is handled by PhysX, which runs in sync with the FixedUpdate timestep - there is no static or event-based DoesThisColliderOverlapThisOtherCollider()
method that you can call on an adhoc basis (the closest is Physics.OverlapsSphere, but it sounds like that won’t help in your case).
However, there’s plenty of generic algorithms to test whether two polygons intersect each other from which you can roll your own method - something like this might be a good place to start: 2D Polygon Collision Detection - CodeProject