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.