Animated Script Variables do not Update

I am trying to use the Properties in the Animation Window to animate a variable within a Script. The gif shows the Property properly updating when the animation is played in the Animation Window, but not when it is played in game.

I’ve submitted a report and have provided my project and other relevant links:

Anyone have similar problems or suggestions for a work around? I’ve also tried using the Animator’s Parameters, but for some reason the Animation Window isn’t letting me add them to my Animation, which is a different problem.

2258950--151028--AnimatedScriptVariable.gif

Thanks for reporting this bug, we will take a look

You can create animation curve that drive animator parameter in the animation window if your clip is not read only, or in the model importer as additionnal curve. In the model importer you need to give the same name to your curve than the animator parameter’s that you want to animate

I’ve also tried using an animator parameter, however it is showing as missing as shown below:

Also in the image it can be seen that retrieving the hash for the animator gives me an ID, but claims that it does not exist retrieving it in script.

I’m using animator.GetFloat(animator.parameters[0].GetHashCode()).

Should I report another bug as it is a separate occasion? Don’t want to unnecessarily bloat your incident reports.

That is not correct. You need to use
http://docs.unity3d.com/ScriptReference/Animator.StringToHash.html

Thanks for the quick response!

It is now finding the animator parameter in the script properly, but now has the same problem as reported initially with Animation Properties. The Animator Parameter reads proper values when playing in the Animation Window, but not during playing, either through the Inspector or while printing out the value to the Console.

Obligatory GIF:

If there’s anything else I can do let me know, thanks again! <3

Which version are you using? I just did a quick test in 5.2 and this is still working

5.1.2f, I’m downloading the beta now to upgrade and see how it works. I’ll report back after it finishes.

Thanks Mecanim.Dev =D

Updated to 5.2.01f and the Animator Parameter no longer shows as missing in the Animation Window as a Property, however I am still unable to retrieve its value in script in anyway.

I currently have these lines of code:

void Update()
    {
        print(animator.GetFloat(Animator.StringToHash("VelX")));
    }

void OnAnimatorMove()
    {
        animVelXParam = animator.GetFloat(Animator.StringToHash("VelX"));
    }

GIF:

EDIT: So by placing the key with Mouse Click and Drag instead of typing in the value, I have it outputting values to the Inspector and Console now, but they aren’t the right ones…really bizarre behavior. I can provide a GIF or Project of that behavior if necessary.

EDITEDIT:
GIF with Mouse Click + Drag:

Yes please log a bug with your project showing this issue.

Submitted, if there’s anything else I can do to provide you guys with more information to pinpoint it let me know. There’s a variety of methods and different weird behaviors I can repro and take videos if needed.

Bug Link: https://fogbugz.unity3d.com/default.asp?721645_cvvuof2571rec4e8

Thanks again and good luck!

Thanks, the bug is been investigated