I am working on a 2d game and I want to be able to replace the animator controller via code when the player picks up a set of armor (gold or silver). I made three different player prefabs (norm,silver, and gold) with their own animations and controller. I thought that it might be easy just to replace the animator controller and the sprite in the sprite render.
I am not sure if this is even the correct way. Any suggestions?
Instead of replacing the individual components of your player with code, which you would then have to initialize according to your specifications, you could just completely replace the player object with each of your prefab player objects when the event occurs. Any logic or data you have that needs to persist can be decentralized to other classes so you can have the flexibility of using those prefabs that you already have customized the way you want.