Hi there!
I’m not so good at scripting so I got some problems…
I have put 3 animations on a GameObject;
Idle
Walk
Sprint
I want the “Idle” animation to play whenever I go into PlayMode.
I want the “Walk” animation to play when I press “W,S,D,A” on my keybord
I want the “Sprint” animation to play when I press “Left Shift” on my keybord
My “Idle” animation works fine…Except it never stops, Even if I play a new animation.
When I press “W,S,D,A” nothing happens.
And the same thing with my “Left Shift”.
I have made a script that should work:
#pragma strict
function Start ()
{
}
function Update ()
{
//Button Down
if (Input.GetButtonDown(“Horizontal”) || Input.GetButtonDown(“Vertical”))
{
animation.Play(“Walk”, PlayMode.StopAll);
animation.Stop(“Idle”);
}
if (PlayMode)
{
animation.Play(“Idle”);
}
if (Input.GetButtonDown(“Sprint”))
{
animation.Play(“Sprint”);
}
//Button Up
if (Input.GetButtonUp(“Horizontal”) || Input.GetButtonUp(“Vertical”))
{
animation.Stop(“Walk”);
animation.Play(“Idle”);
}
if (Input.GetButtonUp(“Sprint”))
{
animation.Stop(“Sprint”);
}
}
Can anybody help me out?
Thanks for your help!