I need help with a game I’m making, I am a beginner in Unity. I trying to make a bomb launcher and when you place a bomb it will
detonate after a certain a mount of time. But when the object is destroyed it won’t recreate so here’s the current code I have so far:
#pragma strict
var detonator : GameObject;
function Update () {
if(Input.GetButtonDown("Fire1")){
Instantiate(detonator,transform.position,transform.rotation);
}
}
that code creates the detonater `
#pragma strict
var explosion : GameObject;
var bomb : GameObject;
var timer : int = 100;
var startTimer : boolean = false;
var placeBomb;
function Update () {
if(Input.GetButtonDown("Fire1")){
startTimer = true;
}
if(startTimer){
timer--;
if(timer==0){
Instantiate(explosion,transform.position,transform.rotation);
Destroy(gameObject);
}
}
}
this code destroys the detonator after a certain amount of time
if you can help thats great thank you