Hello again everyone!
Bakos133 here.
I am trying to find the front center of a dynamically adjustable group of objects.
For example,
The script I am using adjusts the center of a group of game objects dynamically as you build upon it.
(row of 3 blocks, center is 2nd block, row of 4 blocks center is between 2nd and 3rd block, etc.)
What I need to do is find the FRONT CENTER(aka the max.z) of this group of objects and instantiate an object offset on the z axis a little.
The code:
function Start () {
}
function Update ()
{
var combinedBounds = renderer.bounds;
var renderers = GetComponentsInChildren(Renderer);
for (var render : Renderer in renderers)
{
if (render != renderer) combinedBounds.Encapsulate(render.bounds);
print(renderer.bounds.max.z);
}
}
The code I am using currently sets the bounding box in the center of my created object, but it is printing the “bounds.max.z” of the empty game object I am using as a parent.
If you guys can help me figure this out, it would be greatly appretiated!
So once again, I am having troubles finding is:
-
Positive z axis of object
-
Center of positive z axis
Sincerely,
Bakos133