Hi, I am having a problem with one of my scripts. The script itself is working fine, the problem is just when the child GO is changed (rotation/position) and the script is checking the parent of this GO, it reads rotation/position of the OnScreen GO and not the data that has just been set. Is their anyway that I can get the data I just set or force the child GO to update?
I can't really post the whole script so here is the function explained:
foreach collider in ColliderArrayStartingWithLowestChild {
ChildrenColliders = Get all Colliders of the direct children;
CalculatedNewBoundary = Calculate the max Bounds of all ChildrenColliders.
//Includes rotations aswell. Sort of get the Max Cube around all Colliders.
Set this collider.gameObject.localScale = CalculatedNewBoundary;
//This will change the current Collider of the gameObject aswell
Set this collider.gameObject.localPosition = CalculatedNewBoundary.center;
//I would like to update the curren GO here!
}
My Problem being, the lowest Child Collider is changed, its parent Collider is still using the information from the previous frame. Could someone explain to me how I can either work around this or update the GO? There are to many GO for me to wait a frame after each update, would be like 80 frames per update. That would be like if you changed the inner most GO, you would have to wait 2 seconds.
Here is the main bit of the code:
Bounds markerBounds = markerbox.GetComponent<BoxCollider>().bounds;
Vector3 minCorner = markerBounds.min;
Vector3 maxCorner = markerBounds.max;
Vector3 newRotation = markerbox.rotation.eulerAngles;
newRotation.y = (360 - newRotation.y);
minCorner = (Quaternion.Euler(newRotation) * (minCorner - markerBounds.center)) + markerBounds.center;
maxCorner = (Quaternion.Euler(newRotation) * (maxCorner - markerBounds.center)) + markerBounds.center;
float widthMaxTemp = maxCorner.x;
float widthMinTemp = minCorner.x;
float depthMaxTemp = maxCorner.z;
float depthMinTemp = minCorner.z;
float HeightMaxTemp =maxCorner.y;
if(widthMaxTemp > widthMax) widthMax = widthMaxTemp;
if(widthMinTemp < widthMin) widthMin = widthMinTemp;
if(depthMaxTemp > depthMax) depthMax = depthMaxTemp;
if(depthMinTemp < depthMin) depthMin = depthMinTemp;
if(HeightMinTemp > heightMax) heightMax = HeightMaxTemp;
Debug.Log("Innersize("+widthMax+"/"+widthMin+":"+depthMax+"/"+depthMin+":"+heightMax+"|"+markerBounds.size+"/"+markerbox.rotation.eulerAngles);
asked
Jul 02 '10 at 01:45 PM
Ent
76
●
12
●
13
●
20
have you tried using LateUpdate to catch all the changes?
yes, this only works if i have 2 layers. I can set the lowest child in the update and read the data in the late update for the 1. parent. But there are multiple parents after that, that need to be set aswell.
Ive tried using and storing a new bound, this didnt work either for some reason :(
There are 4-6 layers til now, I'll guess I will have to do it over the frames, every frame 1 layer until all layers are done.
did you solve your problem?