I have an hierarchy (h) consisting of a couple of different collider2D:s. h1 is the parent.
h1 is a BoxCollider2D
h2 is a BoxCollider2D
h3 is a PolygonCollider2D
I would like to implement a function that can take the hierarchy h and a positition, and then have it determine if the hierarchy would fit at that position (return true), or if any of its colliders would intersect (return false).
(See attached image for more detailed explanation)
My approach so far has been to recursively go through the nodes in the hierarchy, and then calculate the top-left/bottom-right corners on each child’s “would-be” position, and test with Physics2D.OverlapAreaAll on each one. This feels very fiddly, also it won’t really work with polygon colliders.
Any suggestions on better approaches? I’m very grateful for any push in the right direction. Cheers!