- Home /
make an object explode
hello , I'm creating a game where objects ( spheres) fall from the top of the screen to the bottom , when the user presses a key the object explodes. The problem i'm facing is that i have two rows of objects and when I press a key the object on both rows explodes , I only want one object to explode at a time. I've also created a counter to count the objects that have exploded when the user pressed the right key but, for some reason as soon as the object explodes the counter disappears :/ !!
maybe your counter is attached to the object that get destroyed
yes it is , how can I destroy the object but count it at the same time ?
Answer by nesma · Oct 18, 2014 at 05:13 PM
yes it is , how can I destroy the object and count it at the same time ?
Answer by 767_2 · Oct 18, 2014 at 05:18 PM
you should make counter script and attach it to a empty game object not the one that destroys
you should call your counter script when an object is destroyed
I know I've asked a lot X_X is there anyway that I can have each object independently destroyed? I have two rows of objects and whenever I press the " k" button both objects are destroyed , I can't seem to figure out why ? I want when I press the " k " key once the 1st object is destroyed and then when pressed again the 2nd object is destroyed , for some reason both objects are destroyed at the same time
Answer by Sethhalocat · Oct 18, 2014 at 05:22 PM
Sorry this is short but it didn't let me post before so... as I said.before even though it didn't post. Check to see if the same script is in both game objects and if the key code that you are required to hit is the Same. If it is then use a yeildwaitforseconds.(5) or something along those lines.
wait , I don't want the object to wait the amount of seconds I give it to explode , I want it to explode when i hit the right key for example if i press "k" I want the object to explode and the counter++ I'm sorry this is all new to me XD