How to Make my Character Run?

Hi, I’m using MECHANIM and I’m having some issues. Essentially, when I press LeftShift, I want to be able to toggle the boolean “IsRunning” (my running animation boolean in MECHANIM) to true, in the else statement set it to false. Buuuut, of course, since I have no idea what I’m doing quite yet, I need your help. This is what I got:

	//SPRINTING
	if(controller.velocity.magnitude > 0 && Input.GetKey(KeyCode.LeftShift))
	{
		theAnimator.SetBool("IsRunning", true);
	}
	else
	{
		theAnimator.SetBool("IsRunning", false);
	}

Just to let you know, I did this at the beginning of the script:

var theAnimator : Animator;

Well that’s about it, hopefully you can help me out on this one!

(NOTE: The script gives NO errors, but when I press LeftShift, nothing happens)

You may not be getting the Animator object. Your script should look something like this:

var theAnimator : Animator;

function Start() {
    theAnimator = gameObject.GetComponent("Animator");
}

function Update() {
    if(controller.velocity.magnitude > 0 && Input.GetKey(KeyCode.LeftShift))
    {
        theAnimator.SetBool("IsRunning", true);
        Debug.Log("IsRunning is set to true");
    }
    else
    {
        theAnimator.SetBool("IsRunning", false);
        Debug.Log("IsRunning is set to false");
    }
}

Also realize that Update is called each frame so, unless the shift key is being held down, IsRunning will be set back to false.