Eugene2020-03-25 11:37:11
Eugene, 2020-03-25 11:37:11

After animating a sprite in a unit, the animation stopped mirroring, how to solve?

I'm making a simple platformer on Unity, and I ran into such a problem. The character stopped mirroring after it was animated (for example, if the character goes forward, then everything is fine, but if it goes back, it still looks forward

. Here is the code that is responsible for running, and for something that the animation would be mirrored

private void Run()
    Vector3 direction = transform.right * Input.GetAxis("Horizontal");
    transform.position = Vector3.MoveTowards(transform.position, transform.position + direction, speed * Time.deltaTime);
      sprite.flipX = direction.x < 0.0F;
    if (isGrounded)State = CharState.Run;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
GavriKos, 2020-03-25

Mirror not the sprite itself, but the parent container.
In general, as practice has shown - to work from the animator and from the code with one transform - so-so.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question