Trigger once per object

I did explain what trigger once does and why it is important
But seems you did not get it

So look at trigger once this way
Wait 1st of all full name of it is trigger once WHEN TRUE

Meaning
If conditions above it are true
Run action ONCE

So again lets go to youtube example
Literally open any youtube video
Now wile its playing press and hold 3 on your keyboard

What you are experiencing is how action is executed without trigger once
So as long as condition is true (keyboard key 3 is pressed)
Run action
So since on each game frame you are holding 3 on each frame this action is executed
And this action is jump to 30% of video play time

Now if you would have there trigger once in events
You would press and hold 3
Like hold it until you die or even longer
Then video would jump to 30% but ONLY ONCE
And then it would keep on playing
Cause condition was satisfied you did press 3 on keyboard
And you had there trigger once so it did jump to 30%

And it is not going to spam it each frame cause it did it once already

THAT is what trigger once is doing
Until you release 3 and press it again
Video will NEVER again jump to 30%

NOW with time from start it is like

Your timer is looping around some number
Let’s simplify it
Imagine its going 0 1 2 3 4 5 0 1 2 3 4 5 0 1 2 3 4 5
And in gdevelop you CANNOT check if timer is EQUAL to 0 or 1 or 2 or 3 or whatever
Well you can but you will more often miss it being that EXACT value on frame it will try to check it
Because your timer is not equal to 1 for example when its 1,00000001
So you are asking engine to check if on any of frames it is exactly 1 a fully integer number no fractional decimal BS
That is the issue here
That is why timer condition in gdevelop
DO NOT allow you to check if timer value is equal to
BUT equal or less than
And Equal to or grater than

And since you just want to check if your timer is above 2 seconds
To kick in action
You would spam that action constantly each frame if timer is above 2 secs
That is why you shove in there trigger once

So now timer is above 2 secs but your action was executed only once
Other trick with timers is to check if timer is greater than 2 secs
And then in action alongside your action like idk play sound you shove in there reset timer action

And that is also like trigger once
Cause on 1st frame it will catch timer be anything above 2 secs
It will reset timer
But on that very frame (like i told you in previous message) ALL your events need to run
So action from that event needs to run now
So you played sound reset timer
And what happens on next frame?
You do not play sound again and you do not reset timer
Because it is not above 2 secs anymore
It was reseted on previous frame

Armed with that knowledge
Remember how i told with trigger once condition that was true needs to become false to be able to again become true and be triggered again?
We are checking if value is greater than 2

0 1 2 Trigger once execute action one 3 4 5 0 here condition become FALSE 1 2 here condition become true again

So lets mark it with
F as False
TTA as Trigger once and True A as action got executed once

F0 1 2 TTA 3 4 5 0 F 1 2 TTA 3 4 5 0 F 1 2 TTA 3 4 5

And so go on
So you see trough that loop it becomes true execute it once
And then when loop starts over it become false to be able to be executed again after becoming true again

Now do not think about 0 1 2 3 4 5
Thing about 0,01 and grater than 2

Now you get it?

1 Like

…LOL,thaz big… :joy:

i guess the more he’ll works on his game the more he’ll get used to it.

do u want a simple way to learn a trigger once?..

just create any object at mouse position without trigger once…

1 Like

The “trigger once” help page may help:
https://wiki.gdevelop.io/gdevelop5/all-features/advanced-conditions/trigger-once/

1 Like

Judging from his last message he perfectly is aware what trigger once do
But he does not understand why it is important when you loop some number around like a timer

Because by mistake he was checking if timer value which is looped is below 0,01 so it did look like action was triggering once for him
Where in reality he did not notice it was triggering multiple time on each frame from 0,00000000000000000000 to 0,01

Like helicopter propellers
They moving fast enough will fake effect of not moving
You will believe they are motionless which will be not true

That is why he do not get why trigger once is important in checking if timer is GREATER THAN some value
He assumed it will work perfectly fine without trigger once as it was working when he by mistake was checking if value of looped timer is below very low value

1 Like

I get it now, thanks m8 and everyone else for giving their 2 cents.
And it’s not at all out of fear of having the post double in size again.
Joking

2 Likes