Hey.
I'm trying to make a game. The player will be able to plant bombs, which blow up a set amount of time (2 seconds) after they are planted. I tried creating a private variable which was set to the TickCount whenever a bomb was created, and an event that constantly checked to see if the tick count had gone 100 above the variable's value (100 ticks 50 fps = 2 sec). However, what happened instead was that all of the bombs planted in the first two seconds of the program running would explode at the same time after 2 seconds had finished. I thus assumed that this was because when you create a private variable, it only has one value for the entire object, rather than each instance of the object having its own value. How do I make a variable for each instance of the Bomb object that the player creates?
Thanks.
Checking the tick count won't work. The reason for that is because every time 100 ticks elapse, all existing bombs will be destroyed at that time. Instead of checking the tick count, set a life variable on the bombs to 200. If the value of the variable is over 0, subtract 100 * TimeDelta from the variable. Then, when the life value is equal/less than 0, destroy the bomb. Here's an example: Time Bombs
Hope this helps.
Develop games in your browser. Powerful, performant & highly capable.
Well, I already figured out a way to kind of "cheat" at it using the animator. However, I'm sure that will come in handy later---thank you.
Okay, I have another question. What does it mean when the application test window suddenly closes? What causes that?
EDIT: Nevermind, I'll make a new post.
EDIT2: Nevermind again, I figured it out