How to use WaitForSeconds when changing animations randomly in Coroutine

Hello there, welcome :slight_smile:
Please read this page for how you can post code that shows up nicely on the forums: Using code tags properly

I think this solution might work for you…

void Start() {
   StartCoroutine(IdleChanger());
  }
IEnumerator IdleChanger() {
  // cached wait for seconds variable for subsequent use.
   WaitForSeconds wfs = new WaitForSeconds(3);
   while (true) {
      yield return wfs;
        // random integer range of 0, 10 gives 0 -> 9
      anim.SetInteger("RandomIdle", Random.Range(0, 10));
      }
  }

This will randomly change the animation (assuming your animator is setup correctly) every 3 seconds. Or at least pass a different random value every 3 seconds, and you have your different idles… however that is :slight_smile:

Please delete the StartCoroutine from Update lol :slight_smile: That will make a new coroutine every frame. You do not want that.
If Update() is empty after you delete that, delete the entire update method from the code, too :wink:

Hope that helps.