**I’m a newbie with scripting… But I tried my best to get my animation’s working on the right time… I wanted to
- play my run animation when left shift is pressed and we were not walking or idle
- to play my idle when you are not running / walking
- to play my walk animation when were not running or idle
This may be a dumb question, but this script get this error:
Expressions in statements must only be executed for their side-effects.
Here is the script:**
#pragma strict
var idle : boolean = false;
var walking : boolean = false;
var running : boolean = false;
function Update () {
//make the idle animation play when you are not walking or running
if(walking == false && running == false)
{
animation.CrossFade('Idle');
idle == true;
running == false;
walking == false;
}
//Make the walk animation play when you are not Idle or running
if(Input.GetKey(KeyCode.W))
{
animation.CrossFade('Walk');
walking == true;
running == false;
idle == false;
}
//Make the run animation play when you are not Idle or walking
if (Input.GetKey(KeyCode.LeftShift) && Input.GetKey(KeyCode.W))
{
animation.CrossFade('Run');
running == true;
idle == false;
walking == false;
}
//Make the walk animation stop when the W key is released
if(Input.GetKeyUp(KeyCode.W))
{
animation.Stop('Walk');
walking == false;
running == false;
idle == true;
}
//Make the run animation stop when the left-shift key is released.
if(Input.GetKeyUp(KeyCode.LeftShift))
{
animation.Stop('Run');
running == false;
}
//Make the run or walk animation stop when you are not running or walking
if (Input.GetKeyUp(KeyCode.LeftShift) && Input.GetKeyUp(KeyCode.W))
{
animation.CrossFade('Idle');
running == false;
idle == true;
walking == false;
}
}
Some-one who can help me get this working?