Projext/Assets/Scripts/Player/Animation.cs
2026-02-02 17:30:23 +09:00

39 lines
1.3 KiB
C#

using UnityEngine;
public class PlayerAnimator : MonoBehaviour
{
[SerializeField] private Animator anim;
[SerializeField] private PlayerHealth health;
// ⭐ 추가: 진짜 공격 로직이 있는 스크립트 연결
[SerializeField] private PlayerAttack attack;
private void Awake()
{
if (health != null)
{
health.OnHit += () => anim.SetTrigger("Hit");
health.OnDead += () => anim.SetBool("Die", true);
}
}
// ---------------------------------------------------------
// ⭐ [애니메이션 이벤트 전달자]
// 애니메이션 창에 적은 이름과 똑같은 함수를 만듭니다.
// ---------------------------------------------------------
public void StartWeaponCollision()
{
if (attack != null) attack.StartWeaponCollision();
}
public void StopWeaponCollision()
{
if (attack != null) attack.StopWeaponCollision();
}
// ---------------------------------------------------------
public void UpdateMove(float speedValue) => anim.SetFloat("Speed", speedValue);
public void TriggerAttack() => anim.SetTrigger("Attack");
public void TriggerThrow() => anim.SetTrigger("Throw");
public void SetCharging(bool isCharging) => anim.SetBool("isCharging", isCharging);
}