- Home /
Reset other animations on screen
Hello I have two simple animations controlled by individual GUI buttons. When the Red Button is pressed a red object slides onto the screen. When the Black button is pressed a black object slides onto the screen. I created these animations within Unity. Right now if I press each button both objects can slide onto the screen. I need to only have one object at a time on screen I would like to program it so when each button is pressed the other animation goes back to its starting point off screen. Is there something I can add to make this happen. Here is the code for the buttons. Thanks your help is greatly appreciated.
button 1
function OnGUI () { if (GUI.Button (Rect (10,10,70,20), "RED")) {
animation.Play("Redinfo");
}
}
button 2
function OnGUI () { if (GUI.Button (Rect (10,10,70,20), "BLACK")) {
animation.Play("Blackinfo");
}
}
Your answer
Follow this Question
Related Questions
how to make a animation play only when I get into the range of that game object? 2 Answers
On collision play animation 1 Answer
Retrieving the name of the animation currently playing 9 Answers
play animation doesn't work 2 Answers
How to make player attack animation play through without holding down a key. 0 Answers