Is there a way of testing if one object fully or partially contains another? I have a method that works but relies on using a bunch of empty child objects in the target object. I’ve done it this way instead of using an array because it’s less error prone to set up but it’s still quite time consuming and I have a lot of targets to be dealt with. I’d much prefer to do it purely Algorithmically with reference to the meshes but it’s beyond my knowledge at the moment.
BTW i’ve found Transform.DetachChildren but i can’t see Transform.AttachChildren (i.e. make an instantiated object the child of another). I presume it’s not GameObject.AddComponent.
Hi,
I am not sure I understand the main question about the object being contained by another object. Are you trying to determine if an object is a child, grand child, grand-grand child etc. of some other object? If so, I think you can just loop through the parents i.e. get the parent of each object until you get to the root.
for the second question you should look at Transform.parent
I mean literally, so that all points on the surface of one object are bounded by the interior surface of the target object (which is translucent). To do it accurately is not as trivial as you first might think. Unless of course there’s something lurking in Unity that might be relevant. It can’t really be handled by an array because in many cases there are multiple arrangement solutions some of which may be unknown.
I don’t believe there is anything out of the box waiting for you to do that sort of detection, no. You’ll need to write your own routine, hopefully one that can rely on simple bounding box information first for speed.