코어, 벽, 적의 생성 및 충돌, 데미지 판정

This commit is contained in:
2026-01-12 13:09:08 +09:00
parent a0cf82e97e
commit 5e2eaee44b
24 changed files with 732 additions and 25 deletions

View File

@@ -0,0 +1,26 @@
using UnityEngine;
public class EnemyAttack : MonoBehaviour
{
[Header("Attack Settings")]
[SerializeField] private float damage = 10f;
[SerializeField] private float attackCooldown = 1.0f; // 공격 간격 (1초)
private float _nextAttackTime = 0f;
// EnemyAttack.cs
private void OnCollisionStay(Collision collision)
{
if (Time.time >= _nextAttackTime)
{
// 상대방에게서 IDamageable 인터페이스가 있는지 확인
IDamageable target = collision.gameObject.GetComponent<IDamageable>();
if (target != null)
{
target.TakeDamage(damage);
_nextAttackTime = Time.time + attackCooldown;
}
}
}
}