플레이어 감지 콜라이더 플랫폼과 충돌하지 않도록 수정

This commit is contained in:
Mingu Kim
2025-02-08 19:01:23 +09:00
parent 497e1a495b
commit 4c4e671921
6 changed files with 346 additions and 319 deletions

View File

@@ -56,7 +56,7 @@ namespace TON
_spriteRenderer.flipX = !(_direction.x > 0);
_collider = GetComponent<Collider2D>();
// TODO: 몬스터 방어력 세팅 임시값
// TODO: 몬스터 방어력 임시값
defencePower = 10f;
}
@@ -98,10 +98,13 @@ namespace TON
}
}
if (_isHit)
{
}
// if (_isHit)
// {
// _animator.SetBool("Attack", _isDetect);
//
// _isWalking = false;
//
// }
_animator.SetBool("Walk", _isWalking); // 걷기 애니메이션
}
@@ -155,13 +158,20 @@ namespace TON
private void OnCollisionEnter2D(Collision2D other)
{
_isDetect = true;
if (other.collider.CompareTag("Player"))
{
_isDetect = true;
_animator.SetBool("Attack", _isDetect); // 공격 애니메이션 재생
_animator.SetBool("Attack", true); // 공격 애니메이션 재생
MonsterAttack(other.gameObject); // 플레이어에게 공격
Debug.Log("감지됨");
}
if (!other.collider.CompareTag("Player"))
{
_isDetect = false;
}
}
}
}