FantasyAsset/Assets/Scripts/Behvaiours/ProjectileDamage.cs

22 lines
504 B
C#
Raw Normal View History

2025-08-12 12:39:09 +05:00
// ProjectileDamage.cs
using UnityEngine;
public class ProjectileDamage : MonoBehaviour
{
public float damage = 10f;
private void Start()
{
this.gameObject.GetComponent<SpawnHitVFX>().go = this.gameObject;
2025-08-12 12:39:09 +05:00
}
2025-08-12 12:39:09 +05:00
void OnTriggerEnter(Collider other)
{
if (other.TryGetComponent<IDamageable>(out var target))
{
this.gameObject.GetComponent<SpawnHitVFX>().Impact();
2025-08-12 12:39:09 +05:00
target.ApplyDamage(damage);
2025-08-12 12:39:09 +05:00
}
Destroy(gameObject);
}
}