metahunt/Assets/Scripts/Utils/ActionHelper.cs
2024-02-11 13:53:18 +05:30

34 lines
667 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ActionHelper : MonoBehaviour
{
public float destructionTimer = 0;
public bool usingPool = false;
float t;
private void Awake()
{
t = 0;
}
private void Update()
{
HandleDestruction();
}
void HandleDestruction()
{
if (destructionTimer <= 0) { return; }
if (t < destructionTimer)
{
t += Time.deltaTime;
}
else
{
if (usingPool) { ObjectsPool.instance.ReturnItem(gameObject); } else { Destroy(gameObject); }
t = 0;
}
}
}