Have animator of a gameObject change to a new one

I’m not sure how to go about this. and looking through the other question I seem a bit daunted on how to change my sprite AND animation at the same time. Changing a sprite seems to be easy, but animation seems to add a whole new twist.

I understand that I can do something like this

public Sprite plantCell;
this.gameObject.GetComponent<SpriteRenderer>().sprite = newSprite;

which would change my current sprite to a new one. But the issue is my sprite is animated so it rotates though a few images. When I change it to a new sprite it just gets overwritten back to my animation. I do have a new animation for the new sprite. Is there an easy way to do this?

Basically the same way. You’ll want a controller for each sprite; if your animations just change sprites, you can just swap out the controllers and let the animations change the sprite for you.

public RuntimeAnimatorController newAnimator;

GetComponent<Animator>().runtimeAnimatorController = newAnimator;