How to change the animation speed of a certain animation clip within a blend tree by C# script
Would anyone please help me?
I want to change the animation speed of a certain animation clip within a blend tree by C# script (programmatically) in a game in unity version 2020.2.x.
I tried the following:
set the AnimatorState's (the "Grounded" state in the example picture above) m_ObjectHideFlags from 3 to 1, so that I can pass speed multiplier to the blend tree.
wrote the following code snippet to pass a speed parameter (based on my character's velocity) with the following script.
var velocityXZ = Vector3.Scale(rigidbody.velocity, new Vector3(1, 0, 1));
animator.SetFloat("speed_multiplier", velocityXZ.magnitude);
The result is that it changes the speed of "ALL" animation clips within a blend tree...so this doesn't work.
I want to change only the speed of my running animation clip (the "StandardRun" animation clip in the example picture above) to prevent foot sliding.
Your answer
Follow this Question
Related Questions
change player position when animation in played 0 Answers
Why isn't my animation looping? 3 Answers
Animation Constantly Playing? 1 Answer
Character rolls forward,but slides back after animation 2 Answers
[2D] Play animation backward. 1 Answer