using UnityEngine; public class SpriteMovementFlipper : MonoBehaviour { [SerializeField] private bool invert = false; SpriteRenderer sp; Vector3 prevPos; void Start() { sp = GetComponentInChildren(); } private void Update() { if ((transform.position - prevPos).x > 0.1f) { sp.flipX = invert; } else if ((transform.position - prevPos).x < -0.1f) { sp.flipX = !invert; } prevPos = transform.position; } }