- Home /
Question by
agiblade · Apr 14, 2020 at 01:17 PM ·
animationtoggle button
Animation Speed Multiplier Remained Unchanged Despite Toggle Change
Hello, I'm new to Unity and I'm using C#.
I've been searching for a solution to this over the internet, but I just can't seem to find one specific enough to solve this one.
Here I have a bool variable A which can be toggled and control the animation speed multiplier. Below I attempted to lower animationSpeed parameter which acts as a multiplier for one of my blend trees' speed, and it works just fine:
if (A==true) { animator.SetFloat("animationSpeed",0.3f); }However, when I tried changing the code in an attempt to return animation speed back to original value after toggle state is set to false, The animation speed won't change to 0.3f even if A is set to true; It will always play in 1.0f speed multiplier:
if (A==true) { animator.SetFloat("animationSpeed",0.3f); } else { animator.SetFloat("animationSpeed",1.0f); }Animation default multiplier is set to 1.0f, and the code is placed within Update().
Why does this happen and how can I fix this issue? Thank you in advance.
Comment
Your answer
Follow this Question
Related Questions
How to run 1 animation, then other 2 Answers
UI Button to Toggle Animation and sound 2 Answers
Can the animation editor create local rotational data? 3 Answers
Adding animation clips via script 2 Answers