- Home /
Randomly play an animation from a list, every random seconds
Hi everyone,
I have a set of animations of different objects in the game that I want to add it into a list, so that I can play each one at random, every 3-10 (random) seconds.
public class RandomJumpScare : MonoBehaviour {
public List<AnimationClip> animations;
void RandomAnim()
{
Animation anim = GetComponent<Animation>();
int rand = Random.Range(0, animations.Count);
anim.Play(animations[rand].name);
}
}
I am struggling to understand what I can do to add those animations that I have recorded into this list, and how I can run this function every 3-10 seconds.
Please help me out guys, I have been stuck with this for quite some time.
Sincerely, Dino
Your answer
Follow this Question
Related Questions
How can I use just one script to move randomly several characters from an array? 0 Answers
A node in a childnode? 1 Answer
How to Detect Touch on a Random String from a List? 1 Answer
how to create random list of two diffrent prefab 1 Answer
Creating a record of values generated with Random.Range 1 Answer