- Home /
The question is answered, right answer was accepted
How to access Animator parameters without names/strings?
Hi guys,
in a script I have a list with all my characters, every one with animations. Now I want to know how many animation there are in each char and start or end them from the Code. Well, its look like this isn't working.
So I would go the way to set up all with animators with a state per animation and a condition to to start or end these by boolean parameters. Now the script will go through every char and get the animator objects. Now I would like to not to have to change the code when I rename a parameter or add one. So here my question: Is it possible to change a parameter (lets say there are only booleans) without knowing the name of them?
An animator has a list of parameters and from there I get the count of parameters. There also is an function to get the Hash code, and a function to set a parameter by the hash code:
if(m_animators[0].parameters.Length > 0){
m_animators[0].SetBool(m_animators[0].parameters[0].GetHashCode(), true);
}
But it seams this isn't the way. With this code I only get an error, that the hash code was wrong. I know I just could access the parameters with the String, get the Hash from there an it would work. But I want to know if this way ist possible.
I found the Answer, and of course ist was easy. You can Get the name with m_animators[0].GetParameter(0).name
Follow this Question
Related Questions
How to access animator parameters with out name/string? 0 Answers
Multiple Cars not working 1 Answer
How do I override an animation in animator? 0 Answers
Distribute terrain in zones 3 Answers