activating run cycle question. .

Hi! I’m new to animation and scripting. . . . especially scripting!! . . . and had a question regarding activating a run cycle. My animation is imported and working in Unity as a split animation (idle, walk, run). I used the script from the manual to get the idle and walk working.

function Update ()
{
if (Input.GetAxis(“Vertical”) >0.2)
animation.CrossFade (“walk”);
else
animation.CrossFade (“idle”);
}

and would like to add another crossfade for “run”. Could I set up an input key like “R” to enable the run cycle to begin? I’d appreciate assistance or direction. Thank You. - paul

Yes, you can use Input.GetKey() or, better, Input.GetButton() to detect the R key being pressed and use that to set a walk/run toggle. Then cross-fade to the appropriate animation cycle depending on the state of that toggle.