Я могу перевернуть игровой объект, но моя проблема в том, что он переворачивается до начала анимации атаки. Я не знаю, как привести это в порядок. Надеясь, что кто-то может помочь.
// Update is called once per frame
void Update () {
if(Input.GetKeyDown(KeyCode.Space))
{
GetComponent<Rigidbody2D>().velocity = new Vector2(4f, 0);
StartCoroutine(enemyReturn());
}
}
IEnumerator enemyReturn()
{
yield return new WaitForSeconds(1.1f);
GetComponent<Animator>().SetTrigger("slimeMelee"); //attack animation
GetComponent<Rigidbody2D>().velocity = new Vector2(0, 0);
Vector3 theScale = transform.localScale; theScale.x *= -1;
transform.localScale = theScale;
}