This commit is contained in:
Sveske Juice 2024-02-03 11:15:22 -08:00
commit a6e8eb31d3
1 changed files with 20 additions and 1 deletions

View File

@ -5,11 +5,30 @@ using UnityEngine;
public class PlayerAnimationHandler : MonoBehaviour
{
Animator animator;
SpriteRenderer sp;
Vector3 prevPos;
void Start()
{
animator = GetComponentInChildren<Animator>();
sp = GetComponentInChildren<SpriteRenderer>();
}
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");