몬스터가 플레이어를 체이싱 한 후 공격범위 안에 들어오면 공격하도록 수정

This commit is contained in:
Mingu Kim
2025-02-28 05:52:37 +09:00
parent 5e893a029f
commit 0bdfc0f544
7 changed files with 152 additions and 637 deletions

View File

@@ -4,28 +4,28 @@ namespace TON
{
public class Attack : MonoBehaviour
{
[SerializeField]
private MonsterBase _monsterBase;
public void SetMonsterBase(MonsterBase monsterBase)
{
_monsterBase = monsterBase;
}
private void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("Player"))
{
_monsterBase.IsAttacking = true;
_monsterBase.IsFinishAttack = false; // 공격 시작 시 FinishAttack 초기화
}
}
private void OnTriggerExit2D(Collider2D other)
{
if (other.CompareTag("Player"))
{
_monsterBase.IsAttacking = false;
_monsterBase.IsFinishAttack = true; // 공격 종료 상태로 설정
_monsterBase.IsFinishAttack = true;
}
}
}