Files
OnlyNPC/Assets/FPS/Scripts/Game/TimedSelfDestruct.cs

24 lines
417 B
C#
Raw Normal View History

2026-05-26 09:46:57 +07:00
using UnityEngine;
namespace Unity.FPS.Game
{
public class TimedSelfDestruct : MonoBehaviour
{
public float LifeTime = 1f;
float m_SpawnTime;
void Awake()
{
m_SpawnTime = Time.time;
}
void Update()
{
if (Time.time > m_SpawnTime + LifeTime)
{
Destroy(gameObject);
}
}
}
}