- Home /
How do I animate my enemy randomly with time?
Hi there! I am currently struggling to animate my enemy character for a class project. Most of the answers I find about animation scripting are about the player character that animates with inputs or about enemies entering a collision area and then following the player triggering animations on certain cues.
What I am trying to do however is simply play my enemy's animations at random over time. The basic idea is like a whack a mole game that will throw rigid body projectiles at you.
My enemy's possible states are...
Underground ("emerge" animation sitting at frame 1, no animation)
Emerging (plays "emerge" animation)
Idling (plays "idle" animation)
Attacking (plays "attack" animation)
Retreating (plays "emerge" animation in reverse, possible through rewind function / ping pong wrap?)
So in play, I'd like to, at random, have the enemy emerge, idle 1-3 times, attack after idle finishes, maybe idle again, possibly attack again after the idle, then retreat back underground.
Also about 2 seconds after his attack starts he'll spawn a prefab rigidbody that flies towards my characters last known location.
All I'm looking for right now though is how to get the guy to animate without user input or any cues from the player at all. Simply randomly do his motions.
I do not know if this is simple or complex, any help is appreciated, I am coding-impaired.
Answer by Noob_Vulcan · May 05, 2014 at 12:24 PM
You Could do Something like this ...
selectJumpAnim = Random.Range(0,2);
if(selectJumpAnim == 0){
myAnim.Play("jump");
}
else if(selectJumpAnim == 1){
myAnim.Play("jumpRol");
}
For doing somethign after some seconds you could use
Invoke("method_name",2.0f);
Your answer
Follow this Question
Related Questions
Make AI walk around randomly until Player is Seen. (C#) 2 Answers
Move Enemy randomly in a range. 3D 0 Answers
Enemy Animation Help 0 Answers
Unity3D AI using animations 1 Answer
How can i Learn Basics of Rain AI 1 Answer