Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Destroying then recreating objects

$
0
0
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

Viewing all articles
Browse latest Browse all 171066

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>