x


manually updating transform on each other dependable GameObjects/Colliders

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);
more ▼

asked Jul 02 '10 at 01:45 PM

Ent gravatar image

Ent
76 12 13 20

have you tried using LateUpdate to catch all the changes?

Jul 06 '10 at 09:54 AM spinaljack

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.

Jul 07 '10 at 02:21 PM Ent

did you solve your problem?

Nov 04 '10 at 05:03 PM headkitgames
(comments are locked)
10|3000 characters needed characters left

0 answers: sort newest
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1701
x1279
x496
x15
x3

asked: Jul 02 '10 at 01:45 PM

Seen: 931 times

Last Updated: Jul 06 '10 at 07:49 AM