+ 1

Facing a problem with c# unity script anybody here to help?

anybody here who could help me with a c# unity script?... i am working on a game where i want to click a ui button to activate an animation and stop+disable the animation after certain time and then enable the animation again whenever that ui button is clicked again.

12th Oct 2018, 9:56 AM
Zen
Zen - avatar
1 Odpowiedź
+ 1
I needed to do something like this as well. I dont know about a "proper" way, but the solution I came up with was to have a second "idle" animation.. In my script where I call the animation I added a timer and a bool. after I call the animation, a timer starts counting. once it reaches the time, I simply call the idle animation instead. I have to goto work, but my script was something simple like this (psuedo code)... private int timer =15; private bool playing=false; if(getKeyDown("a")){ anim.Play("FireAnimation"); playing=true; } if(playing){ timer--; if(timer<0){ anim.Play("Idle"); timer=15; playing=false; } }
12th Oct 2018, 10:13 AM
LordHill
LordHill - avatar