How to use scene and object timers?

1)I don’t understand why must we separate the timers from the “repeat for each GreenEnemy”? I tried to include into the “repeat for each GreenEnemy” section but only one of the “GreenEnemy” will shoot.


2)If I choose “Object timer” the “GreenEnemy” do not shoot if i separate from sub-event or include it.

I’m kind of confused as to when to use which timer.:slightly_frowning_face:

Thanks in advance.:grin:

hi, it is simple
think as timer “enemyshottimer” is greater than is a generic timer there is only one, so each time it is more than 0,6 seconds you do a lot of things (for ecah GreenEnemy object). Your problem there is that you reset the timer before doing the for each, as it is a very short time probably is true before ending the repeat. Try to set a bigget time and see the difference for example 2 seconds.
In option 2) what you are asking for the timer of Enemy bullet, if you have more than one enemybullet Gdevelop will give you the first one (i think, I don’t know how gdevelop does this) as timer is short maybe is always using the same bullet. The timer greater than should be inside the repeat, but you should do a repeat for every enemybullet.
I really think you are messing something here.

Sorry dont really understand >.<

what do you want to do?

I have a few timers in my game; I used scene timers for enemy bullets and variable timers for some other things like temporary boosts. I think you might have an extra word in “Create object EnemyBullet at position GreenEnemy.X(); GreenEnemy.PointY(“Centre”)”

Try deleting “Point” and see if that doesn’t fix it.

I didn’t use centre for mine either just { object.x(); object.y() }, but maybe it’s needed in your game.

As shown in the above code, I want to make both the instance shoot at the same time but i dont understand why must we separate the timer and cant use “repeat for each”.

Or if i separate it why cant i used object timer?

Thanks @Phenomena i tried that but doesn’t affect it i think is the timer i used.

No problem, sorry that didn’t work.

All of my enemies shoot at the same time with a scene timer - although some enemies fire slower than others - and I have my events arranged in pretty much the same order as yours.

If you want your enemies to shoot at the same time, object timers aren’t ideal because they affect different instances of the objects, basically giving each object its own timer and thus would make them shoot at different times.

I think the ForEach conditions need to be arranged as sub-events under the timer because you’re telling GD to trigger that action only when the timer condition is met. The reset action should be fine where it is.

I don’t know how helpful this will be or if you’ve already read it…

http://wiki.compilgames.net/doku.php/gdevelop5/all-features/timers

Thanks for helping will look it up :grin::+1:

You’re welcome :smile:

1 Like