enter image description here
i dont know why i have so many errors my code looks good
void Update () {
if (Input.GetKeyDown("left"))
{
gameObject.transform.Translate(-50f*Time.deltaTime,0,0);
gameObject.GetComponent<Animator>().SetBool("moving",true);
gameObject.GetComponent<SpriteRenderer>().flipX = true;
}
if (Input.GetKeyDown("right"))
{
gameObject.transform.Translate(50f*Time.deltaTime,0,0);
gameObject.GetComponent<Animator>().SetBool("moving",true);
gameObject.GetComponent<SpriteRenderer>().flipX = false;
}
{
else
gameObject.GetComponent<Animator>().SetBool("moving",false);
}
}
i tried to make my character have an animation while moving and also flip to the direction but it gave me errors
New contributor
chuurroos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.