HPbarzissou
This commit is contained in:
25
Assets/_Scripts/EnemyDamageHitBox.cs
Normal file
25
Assets/_Scripts/EnemyDamageHitBox.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user