I need a script that would allow an animation to only be able to play when my game object’s speed is equal to 0. I dont have a clue on how to write a script along these lines, can anyone help me?
Learn how to set your player speed to zero. Learn how to use getComponent. Upon doing that return here Danielson.
What do you mean “set your player speed to zero”? If my game object is not moving, does this not mean it has no speed? Thanks for the reply.
If velocity < threshold, then play animation.
take a look here. this code helps a lot. it like a little controller with speed variable and rotation speed. : Unity - Scripting API: Input.GetAxis
tho, when u press left arrow, the speed variable is gonna be under the 0. so make a new variable ( like CurrentSpeed ) which equals the Absolute of the speed variable used in that code.
the function used for absolute is Mathf.Abs : you can find it here : Unity - Scripting API: Mathf.Abs
and then in the update function you should add a condition.
like :
This is very easy to code. ( I also kinda new to coding but I can tell you that both JS and C# are not that hard to lear.tho, it’s okay if you ask for help sometimes if you really have no clue what to do
)
Hope this helps ![]()