25 lines
698 B
C#
25 lines
698 B
C#
using UnityEngine;
|
|
|
|
[RequireComponent(typeof(Collider))]
|
|
public class EnemyDamageHitbox : MonoBehaviour
|
|
{
|
|
[SerializeField] private float damageAmount = 15f;
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (other.CompareTag("Player"))
|
|
{
|
|
IDamageable player = other.GetComponentInParent<IDamageable>();
|
|
if (player != null)
|
|
{
|
|
DamageInfo info = new DamageInfo
|
|
{
|
|
amount = damageAmount,
|
|
hitPosition = transform.position,
|
|
punchDirection = transform.forward
|
|
};
|
|
player.TakeDamage(info);
|
|
}
|
|
}
|
|
}
|
|
} |