organize scripts
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Tnt : MonoBehaviour
|
||||
{
|
||||
public Light explodeLight;
|
||||
public ParticleSystem explodeParticle;
|
||||
|
||||
public float fuseTime;
|
||||
public float explosionLengthTime;
|
||||
float timer = 0;
|
||||
private bool exploded = false;
|
||||
|
||||
void Update()
|
||||
{
|
||||
timer += Time.deltaTime;
|
||||
|
||||
if (!exploded && timer > fuseTime)
|
||||
{
|
||||
exploded = true;
|
||||
explodeLight.gameObject.SetActive(true);
|
||||
explodeLight.transform.parent = null;
|
||||
explodeParticle.gameObject.SetActive(true);
|
||||
explodeParticle.transform.parent = null;
|
||||
explodeParticle.transform.localScale = new Vector3(0.05f, 0.05f, 0.05f);
|
||||
explodeParticle.Play();
|
||||
|
||||
Destroy(explodeLight.gameObject, explosionLengthTime);
|
||||
Destroy(explodeParticle.gameObject, explosionLengthTime);
|
||||
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user