I’m creating an enemy (Spider_Bot) that moves left and right and at some point (for example, every 4 sec.) it will shoot laser beam (done by creating the laser object and change its height to fit on the battlefield.) then it will gone after another 4 seconds. It works perfectly fine but its only working on one enemy (Spider_Bot) only.
I try to use for each object but it’s not working. I know there’s something that I have done wrong so I hope someone can help me with it. Thanks in advance!
there are timer for objects too.
so each spider can have its own timer.
then you should give each spider a unique id (variable)
when the timer of spider >4, create laser at spider pos and do spider id to the variable id of laser.
when timer of spider >8 and id of spider = id of laser delete laser and reset timer of spider.
I try what you said but again, it works only on one spider bot. I try with and without for each object but it’s not working. Hope you can help me again. Thanks in advance!
Your problem sounds mighty similar to my issue with trigger once and repeat blocks. If it is the same, it’s because of the way that the Trigger Once works (and has a bug, IMO). My original post also has a work around too, which you could adapt to your situation.
i tryed it and it seems object timers did not work the way i was assuming.
also was a little toublesome to actually get them consistently do what there supposed to do.
and the variable laser is needed,
because, as MrMen sad, timer condition with trigger once, does not reset the trigger once, once the timer falls below its condition (omg what a sentence)
@FutureGameDeveloper, looking at your second event snippet, I wonder if you need the “Trigger Once” condition? You’re setting the Attack variable if the first set of conditions are met, so it that won’t get triggered the next time round. And if the second event’s conditions are met, then the object is deleted and won’t exist any longer.
@Slash, that last sentence should be made illegal!
So I copy the commands you use but the problem is still there. It only works on one Spider_Bot. I really need to fix this because I need this to almost all of my enemies where the goal is to make it work to all enemies and not only one. Hope you can help me further because I really need this to work.
I try to remove trigger once. What happens is that at first, first spider bot fires laser. then in the second time, the other spider bot fires laser at a short time then it stops then the first spider bot fires again. In short, it doesn’t work at the same time.
I’ve had a closer read of your events, and the second one isn’t correct - in it you are deleting laser. But you are not specifying which laser in your conditions. So it’ll be deleting a seemingly random laser object. You need to link the laser to the spider_bot, or put a timer on the laser.
I watched a video on YT that shows exactly what I need to do! It only needs “For each object” and link the enemy and the bullet. Now I can create enemies that do many things like an enemy that shoots in 4 directions simultaneously. Thank you so much!