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