- Home /
Null values for float, int and other numericals
Good day, and thanks for reading. I used float parameter of Animator component to control wich animation to play and such. But now i need to use sabe script for alot of same onjects, some of wich may not have that float declared in animatorcontroler. So question is - if i use GetFloat from animator and it doesn`t exist, what will i get? It won`t agree to compare to null because undeclared float is not a null and allweys returns true. But what whill i get as a return from GetFloat if float i`m looking for is not even there?
if(Anim.GetFloat("CurrentSpeed") //Some way to find if this float exists in current animatorcontroller//)
{
Anim.SetFloat("CurrentSpeed", Speed); // Set float to current speed
}
Thanks)
Answer by snorcack · Nov 10, 2016 at 11:18 AM
https://docs.unity3d.com/ScriptReference/Animator-parameters.html
The parameter array returned will have all the defined parameters. You can check against this list to see if your parameter is defined or not.
Works fine, you saved me alot of time Didn`t need to set base value to something enormous like 90000 so speed changes would never achive and check true against it :)
Your answer
![](https://koobas.hobune.stream/wayback/20220612100418im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
What does this statement construction mean?: if (null != anim) 1 Answer
transform does not exist in the current context 2 Answers
Can you help solve the following error? 1 Answer
How to Increase animation speed using a float 1 Answer
Animator changing state changes when triggered when it should change on float change 1 Answer