CharacterWalkRight.Play(); kept throwing an error. However, I see now that there are multiple Clips per animation -- I was making a new animation for each clip, so instead of 1 Animation with 4 Clips (idle/walk for left/right), I had 4 animations each with 1 clip.
Now I have 1 animation with 4 clips, and the following code is working, seems to be more right:
var CharacterAnimations : tk2dAnimatedSprite;
function Start ()
{
CharacterAnimations.Play("Idle Right");
}
function Update () {
if (!didDie)
{
if(Input.GetKey(KeyCode.RightArrow))
{
transform.position.x += moveSpeed;
}
if (Input.GetKeyDown (KeyCode.RightArrow))
{
CharacterAnimations.Play("Walk Right");
}
if (Input.GetKeyUp (KeyCode.RightArrow))
{
CharacterAnimations.Play("Idle Right");
}
}
}
Does that look more correct?