Alternative Method of Flipping Sprite

I believe I found a method of flipping the sprite that will be better for performance. Instead of running the FlipSprite() method every frame, it can be called with OnMove. I also like the control this way offers, as if we give a wind effect that pushes the player back, the negative velocity won’t flip the sprite.

Here’s my code. Maybe I’m wrong and I’m missing something, but it seems to work great. Plays let me know :slight_smile:

void OnMove(InputValue value)
{
moveInput = value.Get<Vector2>();

    if (Mathf.Abs(moveInput.x) > Mathf.Epsilon)
    {
        transform.localScale = new Vector2 (Mathf.Sign(moveInput.x), 1);
    }
}

Privacy & Terms