I can’t the script below to work. It is attached to a game object which also has the “inciseS” script attached to it.
animation["inciseS"].speed = 1.75;
var itoggle : boolean = false;
function Update (){
if (Input.GetKeyDown(KeyCode.I))
itoggle = !itoggle;
if(itoggle)
animation.Play("inciseS");
else if(!itoggle || Input.GetKeyDown(KeyCode.R))
animation.Stop("inciseS");
}
The “R” key doesn’t work to stop the animation; only the toggle button “I” is working to stop the clip. I have the “R” key assigned to toggle a clip on a different game object - could this be why?
I tried like this: else if(!itoggle || itoggle && Input.GetKeyDown(KeyCode.R)) animation.Stop("inciseS"); or also like this: else if(!itoggle || itoggle=false && Input.GetKeyDown(KeyCode.R)) animation.Stop("inciseS"); but it doesn't work; what am I doing wrong?
– anon98041362got it to work, thanks testure! if (Input.GetKeyDown(KeyCode.R)){ itoggle = false; animation.Stop("inciseS"); }
– anon98041362if you're using a sub condition you need to wrap additional parenthesis around it. for example: if(true || (false && false)) Also- don't post comments as answers, it messes up search indexing ;)
– testureThanks again, and won't post comments as answers anymore, my bad.
– anon98041362