I want to set “This” value in the screenshot by script.Is there any way?Please
This answer may be a little late, but I wanted to achieve the same thing and this is how I accomplished it.
In my Blend Tree, I added the same animation with a lower Animation Speed.
Notice how I have the walk
motion twice. One with the speed set to 1
and another with the speed set to 0.5
This allows me to slow the walking animation if the player is pressing lightly on the joystick and speeds the animation up if the player presses the joystick harder.
I added a float
parameter called speedPercent
. In my code, I change the speedPercent
by using:
public Animator animator;
float speedValue;
if( walkingSlow ) speedValue = 0.3f;
else if( walkingFast ) speedValue = 0.6f;
else if( running ) speedValue = 1f;
else speedValue = 0f;
animator.SetFloat( "speedPercent" , speedValue );
This code is just an example, it is not the actual code.
The animator speed property do this, but the animator speed work with all animations, so you have to change the speed for all animations in animator controlling them, for example, if your player movement, need to change the animation speed to run
clip and want the animation more faster, you must change the animator.speed
to 2
. After this when you need to back speed, change the speed back to 1
in idle animation or other animation.
private Animator animator;
animator.speed = value;
all you need change
© 2022 - 2024 — McMap. All rights reserved.
Was asked there as well. https://mcmap.net/q/40577/unity-how-to-access-blend-tree-speed-in-mecanim-from-c
– Ita