Fur-War/Assets/Scripts/ExplosionController.cs
Gerard Gascón 3b4c6e0ec6 init
2025-04-24 17:29:51 +02:00

33 lines
786 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ExplosionController : MonoBehaviour, IPooledObject{
float currentTime;
[SerializeField, Range(0, 3)] float timeToDisappear = 1f;
BoxCollider col;
void Start(){
col = GetComponent<BoxCollider>();
}
// Start is called before the first frame update
public void OnObjectSpawn(){
currentTime = 0;
if(col != null){
col.enabled = true;
}
}
// Update is called once per frame
void Update(){
currentTime += Time.deltaTime;
if(currentTime >= .05f){
col.enabled = false;
}
if (currentTime >= timeToDisappear){
gameObject.SetActive(false);
}
}
}