Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

the length of another objects animation.

Discussion in 'Scripting' started by AaronC, Jun 24, 2007.

  1. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    I'm trying to access another object though varibiles.
    Code (csharp):
    1.       yield WaitForSeconds (Box, animation.clip.length);
    2.  
    Box is another GO assigned via inspector. Im trying to wait for the length of the Box'es"close" animation. The whole function goes like this:
    Code (csharp):
    1. var hingeOpen:AudioSource;
    2. var hingeClose:AudioSource;
    3. var Box: GameObject;
    4. var PickupGraphic: GameObject;
    5. var EmptyBox: GameObject;
    6. function OnTriggerExit(other : Collider) {
    7.    if (other.tag == "Player") {
    8.       Debug.Log("Close");
    9.       Box.animation.Play("close");
    10.       hingeClose.Play();
    11.       yield WaitForSeconds (Box, animation.clip.length);
    12. //that was the buggy line
    13.       Destroy(transform.root);
    14.       Instantiate (EmptyBox, transform.position, transform.rotation);
    15.      
    16.    }
    17. }
    I should be specifically addressing the Boxes' "close" animation, though Im not too sure about how to type it all up...Any suggestions?
    Thanks very much
    AC
     
  2. Talzor

    Talzor

    Joined:
    May 30, 2006
    Posts:
    197
    Use Box.animation["close"].length
     
  3. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    Hey Talzor, I forgot to say thank you....


    Thhhaaannkkk yyooouuu!!!

    This is handy indeeeed...!
    AC