Question by
capocchione · Dec 11, 2020 at 09:09 AM ·
gameobjectsboundsboundingbox
How to put an object on top of another growing object?
I have a group of parent/children gameobjects growing altogether, how can I put another object on top of all these while they are changing shape and scale each update?
I can draw a boundbox around each gameobject:
void OnDrawGizmosSelected()
{
Gizmos.color = Color.magenta;
foreach (var mf in GetComponentsInChildren<MeshFilter>())
{
Gizmos.matrix = mf.transform.localToWorldMatrix;
Mesh m = mf.sharedMesh;
Gizmos.DrawWireCube(m.bounds.center, m.bounds.size);
}
}
So, probably the best way to do is to draw a single boundbox around the whole structure and put the object on top of the boundbox, but I don't know how to do it.
Here it is how it looks like. Notice that a certain point the cylinder splits in two and it is where a boundindbox around the whole "tree" gameobject will come in handy:
boundbox.png
(98.9 kB)
Comment