Generation

generate functionFri, 09 Dec 2022

Choose a random animation from a list Play it When the animation reaches the end repeats the process

// Create a list of animations class myAnimation : MonoBehaviour { public List<Sprite> animList = new List<Sprite>(); void Start() { // Creates a random number int rand = Random.Range(0, animList.Count); // Sets the sprite to a random animation GetComponent<SpriteRenderer>().sprite = animList[rand]; } }

Questions about programming?Chat with your personal AI assistant