Before proceeding, please use the forum search feature at the top of the page to check if your question has already been answered.
How do I…
Hello all, I know that there’s been multiple posts about similar issues, but for the life of me I can’t get this to work.
How do I make individual instances of an object start/reset a timer based on a condition?
What is the expected result
The timer should start on each object which have the condition fulfilled, and continue until I choose to stop it with another event.
What is the actual result
Whatever I try won’t work, I’ve looked at other posts about the same problem but it either gets stuck with the timer as “0” or starts for the first batch of the object and doesn’t exist for the others, or the timer doesn’t exist for any of the objects at all.
Thank you in advance, help would very, very much be appreciated.
Hi you only really need ‘repeat for each’ when you’re doing something really complicated with them and if you do it its better to have all their events under one repeat. (from my experience)
re object timer - There’s no trigger once on starting the timer so unless you’re setting controlled to true straight away it’s restarting each frame.
if you’re doing ‘repeat for each’ its best to keep the object conditions as sub events of the repeat event.
Hey man! First off, just wanted to say thanks for replying. I’m not sure if you remember, but you helped me out when I was first starting out GDevelop. I’ve really been enjoying development since.
That aside, I’ve tried both of what you suggested, and oddly enough they both produced the same result.
I used the repeat event above the subevent, and also tried it without. (Both used trigger once on the subevent which starts the timer)
I spawn these objects with a sort of wave system with the “Controlled” set to false at default, (3 at a time.)
For the first three instances, the timers start just fine. The next timers don’t pop up in the debugger across future instances at all!
My guess is that worst case scenario, I’ll just have to use an object variable which instantly toggles when the timer starts-- weird.
Oh dear …all the pros on here will be shaking their heads muttering ‘this has to end!’
I find it hard to digest event flow on my phone…if I get a chance later I’ll see if I can post how I’d rework the events you’ve got there into something simpler
is that the only event for dashbot? Have you got all the events for dashbot in one place? If I’m using a repeat for each I tend to keep all the conditions as sub events of that repeat and pull all the events related to that object under one repeat for each. It’s also a good idea to use event groups too and put the code relating to that object in there as you can then see how it’s performing in the profiler.
If you’re doing the game jam, and it’s working, then it’s probably better to just move on, and if you get time come back and streamline things.
It’s really hard to digest the subtleties of what you’re up to without seeing the full project. Looking at it - there are things that i would move about to streamline things - but it looks like you’re in the process of quickly sketching things out to see if they work…so just do that and if you run into a problem …post it on here!