Trigger once while true event is not letting my code work?

I needed to add the Trigger once event where im creating the two objects but then the code just stops working when wave 1 is finished and waveend gets set back to 0 it does not run waveend again…

if i remove that trigger once event then it all works but then its constantly creating those objects over and over when its running the waveend code. (trigger event in question is the one under my cursor)

Welcome!
I’m not sure why your logic is not working, I have often times avoided using complicated “Trigger Once” events by instead using boolean logic.

For instance:
Change your “wavend” variable to a boolean, and name it something more descriptive like “TriggerWaveEnd”
Your condition will now be “TriggerWaveEnd is TRUE”, and you will not use the Trigger Once event… instead just do all the the wave end logic that needs to be done and then set “TriggerWaveEnd = FALSE” as the very last event in that block.
Now whenever any where in your logic sets TriggerWaveEnd to true the logic will run exactly once on the next frame and get set back to false.

Hello RudeMice
Trigger once will allow the code to be run only once. So when you reset waveend to 0 it won’t re-execute and recreate your objects. To solve this problem you can use a variable that will let you know if your objects have already been created for this wave like this:

ah i see i thought the trigger once just always worked aslong as it was true and at the end of everyway it would set waveend back to 0 making it true again? thanks for the replies and this solution did not work. but with this idea im sure i can make something work

I will give this a shot and let you no how i got on ty

tried this option but its still creating the text objects more then once even inside the true and false boolean. so not sure what to try next.

The trigger once means just that - run the event once,and then not again while the scene is runnning.

I’d suggest making 2 separate waveend = 0 events, one with a trigger once, the other without :

That should see you right.

1 Like

This solution still did not work. https://i.imgur.com/CG7nUkj.png I have no idea why the trigger once is still stopping the code.

How is it not working? What does it do?

Apply some logic to what’s happening and work it out; from the screen shot you’ve linked, it seems like waveend is set back to 0 once there are no more zombies (I’m assuming Zombie is an object group). So confirm that there are no more zombies in the scene - and that includes off the screen. You can use the debugger to check how many instances of the various zombies there are in the scene when you run the game.

Can confirm all instances of zombies are dead on the screen and off. and its still just doing what i originally posted. only works when i remove the trigger once :frowning: its confused the hell out of me. since the amount of zombies I have spawn each wave is a set amount and i have a killcount variable that i track, I think i will just use the killcount for a trigger for the event instead of the waveend stuff and see how that goes. thank you for trying tho :slight_smile:

So there are instances of Zombies in the scene? Then waveend will not be set to 0.

Or are the dead zombies not a member of the Zombie group?

yeah dead zombies are not apart of the zombie group. I solved it by just having the waveend stuff trigger from the kill count variable anyway so its not how i would of liked it but at least its working :stuck_out_tongue: