when I press play, my walking animation where the sword bobs around back and forth works correctly, but it constantly loops, I want to make it so it’s still when I’m standing, but I want to trigger the animation for when I press W to move, anyone know how to do that?
1 Answer
1private bool Idle = false;
private float Speed = 0;
void Update()
{
if(Speed < 10.0f)
{
Idle = true; // Make Idle true to trigger the Idle animation
}
if(Idle == true)
{
animation.Play ("Sword_Idle"); // Play Idle animation when Speed is less than 10 (AKA 0)
}
if(Input.GetKey (KeyCode.W))
{
animation.Play("Sword_Walking"); // Play walking animation when we are holding W
Speed = 10.0f; // Change speed so we can move
}
}
This should work (P.S this is C#, I can’t code in Java)