33 lines
786 B
C#
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);
|
|
}
|
|
}
|
|
}
|