22 lines
504 B
C#
22 lines
504 B
C#
// ProjectileDamage.cs
|
|
using UnityEngine;
|
|
|
|
public class ProjectileDamage : MonoBehaviour
|
|
{
|
|
public float damage = 10f;
|
|
private void Start()
|
|
{
|
|
this.gameObject.GetComponent<SpawnHitVFX>().go = this.gameObject;
|
|
|
|
}
|
|
void OnTriggerEnter(Collider other)
|
|
{
|
|
if (other.TryGetComponent<IDamageable>(out var target))
|
|
{
|
|
this.gameObject.GetComponent<SpawnHitVFX>().Impact();
|
|
target.ApplyDamage(damage);
|
|
|
|
}
|
|
Destroy(gameObject);
|
|
}
|
|
} |