ina
February 18, 2013, 2:48pm
1
How do you get an enemy to play an animation for one instant and then revert to a default animation?
I’ve tried CrossFadeQueued(“idle”) after calling the damage animation - doesn’t seem to work. Damage keeps on looping and idle is never played again… >.<
anim.wrapMode=WrapMode.Once;
anim.CrossFade ("Damage");
anim.CrossFadeQueued("idle");
anim.wrapMode = WrapMode.Loop;
Try something like this:
animation.CrossFade("hit");
for(;animation.isPlaying;)
yield;
animation.CrossFade("idle");
Griffo
February 18, 2013, 3:40pm
3
Try -
#pragma strict
private var z : int;
function Update () {
if (Input.GetKeyDown ("c")){
z = (z % 2) + 1;
if(z == 1){
animation.Stop("Idle");
walk();
}else{
idle();
}
}
function idel(){
animation["Idle"].wrapMode = WrapMode.Loop;
animation.CrossFade("Idle");
}
function walk(){
animation["Walk"].wrapMode = WrapMode.Loop;
animation.CrossFade("Walk");
}
Or set a boolean when taking damage and do something like -
#pragma strict
var takingDamage : boolean;
function Update () {
if (takingDamage){
animation.Stop("Idle");
damage();
}else{
animation.Stop("Damage");
idle();
}
}
function idle(){
animation["Idle"].wrapMode = WrapMode.Loop;
animation.CrossFade("Idle");
}
function damage(){
animation["Damage"].wrapMode = WrapMode.Loop;
animation.CrossFade("Damage");
}