Orthello animation when sprite is moving

Hi, Im new usign Orthello Framework and I´m tryin to make a simple player control ( move left, right , jump , crouch ) but I have a little proble when the Sprite is moving.

The way I write my code :

public class ControlBasico : MonoBehaviour {


public OTAnimatingSprite mySprite;
 // Use this for initialization
 void Start () {
 
 }
 
 // Update is called once per frame
 void Update () { 
 Vector3 moveDirection = Vector3.zero;
 
 if(Input.GetKey(KeyCode.LeftArrow)){
 moveDirection=  new Vector3(-1,0,0);
 }
 
 if(Input.GetKey(KeyCode.RightArrow)){
 moveDirection +=  new Vector3(1,0,0);
 }
 
 if(moveDirection.>;0){
 mySprite.Play("walkright");
 }
 
 if(moveDirection.<;0){
 mySprite.Play("walkleft");
 }
 
 transform.Translate(moveDirection* Time.deltaTime);
 }
}

(I have only these two animations to play.)

The result : When the Sprite Object is moving left or right in the screen , the animation doesn´t play , the sprite is static and only when the key (left or right) isn´t pressed the animation starts to play again.

I guess I´m doing something wrong, but I can´t see “What…”

Thank you.

Your animation code is in the update function, so you’re gonna end up restarting the animation every frame. Instead of writing:

 if(moveDirection.<;0){
 mySprite.Play("walkleft");
 }

you should write something like

 if(moveDirection.<;0 && mySprite.animationFrameset != "walkleft"){
 mySprite.Play("walkleft");
 }

This checks to see if the animation you want to play is already playing; if it is then we do nothing, if it isn’t then we play it.