diff --git a/Assets/Scripts/Player/PlayerAnimationHandler.cs b/Assets/Scripts/Player/PlayerAnimationHandler.cs index d131f57..ef54b41 100644 --- a/Assets/Scripts/Player/PlayerAnimationHandler.cs +++ b/Assets/Scripts/Player/PlayerAnimationHandler.cs @@ -5,11 +5,30 @@ using UnityEngine; public class PlayerAnimationHandler : MonoBehaviour { Animator animator; + SpriteRenderer sp; + + Vector3 prevPos; + void Start() { animator = GetComponentInChildren(); - + 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; + } + public void Idle() { animator.SetTrigger("Idle");