I’m trying to figure out how to change the animator state during run-time via scripting.
I am not interested in any blending or transitions, simple switching between states and start each animation from the beginning. If necessary I can reload the scene in between, and I have about 200 animator states.
So far, I’ve identified the following functions that can achieve this during run-time, but they are limited to the Unity Editor:
If the transitions between states depend on the values of parameters then you can use a script to set the values of those parameters and thus change the states.
The generated code contains a member called stateDictionary. It’s a HashTable with the hash IDs as keys and the state names as values. Provided that you like to sue the generator, the following code will do the job: