14 lines
437 B
C#
14 lines
437 B
C#
using UnityEngine;
|
|
public class DamageBot : MonoBehaviour
|
|
{
|
|
[SerializeField] private float damageAmount = 10f, damageInterval = 1.0f;
|
|
private float timer;
|
|
private void OnTriggerStay(Collider other)
|
|
{
|
|
if (other.TryGetComponent<IDamageable>(out var target))
|
|
{
|
|
timer += Time.deltaTime;
|
|
if (timer >= damageInterval) { target.TakeDamage(damageAmount); timer = 0f; }
|
|
}
|
|
}
|
|
} |