Hello,
I’m making a bird that can blink randomly but i have no idea how to do it. I have a 3d model of a bird and the bird has an animation on it with a blink. But the bird only plays the animation once but he needs to do it repeatedly and needs to do it after random seconds. no less than 5 or 10 seconds. Help?
Tom Akkerman
Something like this should do the trick. Make sure your animation isn’t set to loop. Attach this to the bird with the animation component and assign the blink animation clip to this component.
public var blinkAnimation:AnimationClip;
public function Start() {
doBlinkAnimation();
}
public function doBlinkAnimation() {
while (1) {
// Wait for 5 to 10 seconds
yield new WaitForSeconds(Random.Range(5, 10));
// Play the animation
var animationName:String = this.blinkAnimation.name;
animation.Play(animationName);
// Wait for the animation to complete
yield new WaitForSeconds(animation[animationName].length);
}
}