Thanks, I removed the condition, but the whole “while” block does not get triggered since the log message “creation of instance started” does not even appear within the logs. I used timers before, I’m really puzzled.
For the time being, it’s hardcoded. If I remove the timers and related conditions, the code creates three instances. But all at the same time, I want that to happen with a delay.
I’ve never had much luck with timers using while loops, an alternative is using the repeat every X seconds X times event of the RepeatEveryXSeconds extension. In practice you can achieve the same effect that you’re trying to do with a while loop and scene timer.
You can use the repeat every x seconds event without making a timer, in fact that could be the reason it’s not working. Try getting rid of the event where you create the scene timer and see if that helps. If it doesn’t work, are you certain there’s not a problem with the structure variables?
@weadsy1, I’m not sure if I understand you correctly. The extension does not contain any actions, only two conditions (one is the one you are referring to, “Triggers every X seconds X amounts of time”).
If I use this one, it does create a timer (which is running, I can see this in the debugger).
However, nothing is being spawned. Here’s the current implementation (without creating the timer upfront):
It contains 2 condition functions that also run events, which start and repeat the timers. Thus creating events outside the extension (in your event’s sheet) that control the same timer could possibly interfere with the extension’s events.
If it’s still not working, then are you sure the condition is evaluating to true? If it is then are you sure the formula that returns the X coordinate is working properly?
Additionally, is this extension being ran every frame?
Regarding the first condition: not sure, tbh. I’m not sure how this is supposed to be used.
The second condition is definitely true.
The x value is getting calculated correctly and the code works as expected when I remove everything related to timing - three instances are being created in the right position.
I just can’t figure out a way to delay the creation of the latter for instances.
The function is being triggered by the value of a variable having a certain value.
Status
=0 → prepare the stage
=1 → create the instances (the step I’m at right now)
and so on.
Since status 2 is not implemented yet, it remains on 1. Does that suffice to run every frame?
Is this a lifecycle function? If it is do you mean that is what is setting the variable, or is the extension itself ran when a variable in the events sheet is a certain value?
My 2 cents. I don’t believe time passes within loops or even the frame that the code is on. I believe some external values like keyboard, mouse and time are only updated between your events. They’re the same value at the beginning of the frame that your code executes and at the end.
While loop events explicitly stop any other events from proceeding until the loop conditions are false, and never process past the current frame until they are done. I don’t believe timers or waits will ever work in while loops due to this.