Animations scripting problem! Help!

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!

Help

HELP

Not quite sure this is the best forum to be asking for help - Animation, Scripting or Support are probably where you should be asking.

That said, your script has a variable “Playmode” which I assume is a boolean and is True for the idle situation. If you start with figure idling then unless you set Playmode to False somewhere it is (re)starting that animation every update. You need to rethink how you start the idle animation.

cheers, gryff :slight_smile:

Stop bumping. We see it. Saying “HELP” once every few minutes will get you nowhere. A good rule of thumb is once a day for bumping. Also, you posted in the wrong section. Gossip is for just that: gossip (not help). Post in in the programming section. On one last note, code tags would make your post readable with the code nicely contained rather than in a mess in the middle of the screen.

But how can i do it? I want the Idle animation to play all time (Just not when another animation is playing). Is there another way to script so it plays constantly?[quote=“gryff, post:4, topic: 524218, username:gryff”]
Not quite sure this is the best forum to be asking for help - Animation, Scripting or Support are probably where you should be asking.

That said, your script has a variable “Playmode” which I assume is a boolean and is True for the idle situation. If you start with figure idling then unless you set Playmode to False somewhere it is (re)starting that animation every update. You need to rethink how you start the idle animation.

cheers, gryff :slight_smile:
[/quote]

Sorry :confused:
I gonna think of that next time! [quote=“UnknownProfile, post:5, topic: 524218, username:UnknownProfile”]
Stop bumping. We see it. Saying “HELP” once every few minutes will get you nowhere. A good rule of thumb is once a day for bumping. Also, you posted in the wrong section. Gossip is for just that: gossip (not help). Post in in the programming section. On one last note, code tags would make your post readable with the code nicely contained rather than in a mess in the middle of the screen.
[/quote]