- Home /
Animator parameter does not pick the value of the animation curve with the same name
Hi, everyone, I am trying to detect a certain point/range in my animation clip from script and I read that the thing to do is to add to the Animator Controller that has the animation a float parameter with the exact name as the animation curve. However, this simply does not work for my project. Any ideas?
Thanks in advance!
Answer by FortisVenaliter · May 01, 2016 at 03:36 PM
No, that won't work. AnimatorController variables get their values from code. and use them for animation decisions, not the other way around.
There are two ways you can do this. You can do it entirely in code, looking at the time values in the Animator's current active clip, or use animation events.
@ FortisVenaliter - I am pretty sure it's possible http://docs.unity3d.com/$$anonymous$$anual/AnimationParameters.html In fact, that's how they trigger the shot effects in the S$$anonymous$$lth Tutorial. I have it working now, I think the issue was that it needed the animation curve to be on all animations in the animator controller...,
Interesting... the docs seem vague on the subject; I've never seen it done, sorry.
True, it's very vaguely described and I have only seen it on this video of the s$$anonymous$$lth tutorial https://www.youtube.com/watch?v=c_1Y-iXaQA8∈dex=23&list=PLX2vGYjWbI0QGyfO8P$$anonymous$$Y1pC8xcRb0X-nP . That's why I could not find a way how to troubleshoot my case, since no one seems to use that feature...
Hello. You're almost right. But it's not neccessary to add curves for all(!) animations. You should add it just on the animation clip that is placed on the animation state machine and state of which should be detected. For example, if you have animation clip "Walk", use it on the state machine for walking animation of your avatar, and wish to detect when your avatar maximally raises the leg during walking - you should create a curve exactly for this clip ("Walk"). Otherwise it will not work.
Answer by floky · Aug 05, 2020 at 03:04 PM
A bit late to this party but I just wanted to leave this up-to-date answer in case it helps anyone else.
As stated by the Unity docs you can have an animator parameter automatically pick up values from an animation curve as long as the animation is being used by the animator controller state. Otherwise the parameter will just have the default set value or any value set by your scripts.
Some extra details are provided at the bottom of this page: https://docs.unity3d.com/2020.1/Documentation/Manual/AnimationCurvesOnImportedClips.html