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