Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

animation.Pause() ???

Discussion in 'Scripting' started by ImperadorJulioCesar, Nov 25, 2010.

  1. ImperadorJulioCesar

    ImperadorJulioCesar

    Joined:
    Nov 11, 2010
    Posts:
    26
    Hi everyone,

    I want to know if it's possible to pause an animation during its execution?

    For exemaple i have an animation of an elevator going up and down, when players rich the top and get out of the elevator the elevator stops and when player get back again in the elevator its start the rest of the animation making the elevator go down.

    example:
    Code (csharp):
    1.  
    2.  
    3. var elevator : GameObject;
    4.  
    5. function Start(){
    6.      //Here i've stopped all the animations at the beggining of the game;
    7.      animation.Stop();
    8. }
    9.  
    10. function OnTriggerEnter(){
    11. //It will play the animation when player gets the elevator;  
    12. elevator.animation.Play("elevator");
    13. }
    14.  
    15. function OnTriggerExit(){
    16. //It will stop the elevator when player gets off
    17. animation.Pause();
    18.  
    19. //I'm using animation.Stop() in my script today, but when player get back to the elevator it begin the animation all over again, not where it stopped.
    20. }
    21.  
    22.  
    Does anybody have an ideia or suggestion?

    Thanks!
     
    Last edited: Nov 25, 2010
  2. Baronium

    Baronium

    Joined:
    Aug 21, 2010
    Posts:
    2
    Last edited: Nov 25, 2010
  3. ImperadorJulioCesar

    ImperadorJulioCesar

    Joined:
    Nov 11, 2010
    Posts:
    26
    Thanks Baronium,

    You've just solved my problems : )