FantasyAsset/Assets/Scripts/Behvaiours/ProjectileDamage.cs

16 lines
329 B
C#

// ProjectileDamage.cs
using UnityEngine;
public class ProjectileDamage : MonoBehaviour
{
public float damage = 10f;
void OnTriggerEnter(Collider other)
{
if (other.TryGetComponent<IDamageable>(out var target))
{
target.ApplyDamage(damage);
}
Destroy(gameObject);
}
}