After checking with the frame-by-frame view in Unity I noticed that despite my console showing a variable updating in real time, my animator.setFloat just doesn’t seem to be doing the same.
It takes a whole lot of frames before the value from the variable is actually sent to the animator and for it to show up in the inspector, and by that time the value gets to the animator it’s already too low to trigger the animation I wanted.
In case I’m not being clear, look at this gif

The value in the console is the variable that’s being sent to the animator.
“Angle” in the animator is the parameter that’s supposed to receive that value.
Notice how long it takes before any number appears there.
Is this normal? Can it be fixed?
This is how I’m sending the value to the parameter, I tried putting it in both Update() and FixedUpdate().
animator.SetFloat ("Angle", charAngle);
My immediate guess is that it’s updating immediately internally, but the display on the editor is not because of the difference in how Updates are run between the two. I’ve never noticed any sort of a lag time like what you’re describing, so if it is an issue, it may be the specific Unity version you’re using.
Or I’m just wrong- always possible.
Just a quick tip- using string values to identify variables is notoriously slow, so I’d recommend using the hash value instead. Simply do Animator.StringToHash(“Angle”) in Awake, and assign that hash result to a class-scope int variable called AngleHashValue or something- then use that hash in place of “Angle” in the SetFloat function. This should be MUCH faster than using the string, and may possibly even account for the discrepency you’re seeing (though I doubt it- it’s a good practice regardless though).
Cheers!
It could be just a GUI repainting delay?
To test it out: set the float, then immediately get it back to see if it was set.
animator.SetFloat ("Angle", charAngle);
var value = animator.GetFloat("Angle");
1 Like