init
This commit is contained in:
commit
3b4c6e0ec6
506 changed files with 434142 additions and 0 deletions
33
Assets/Scripts/ExplosionController.cs
Normal file
33
Assets/Scripts/ExplosionController.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue