[SOLVED] How do I get "tween has finished playing" to work?

How do I…

I want an action to trigger when a tween is finished within a behavior (on creation). Theoretically, this sounds rather straight forward, however, I cannot get it to work, the condition just seems never to be met. What am I missing?

What is the expected result

The condition is met and the action are triggered.

What is the actual result

The condition is never met.

Related screenshots

What happens if you remove the trigger once on the second event, and add an action to remove the tween instead? That’s the way I usually deal with tweens.

1 Like

Thanks @MrMen for your feedback.

I fear I don’t understand the point of removing the tween.

My problem is: The tween influences a value I need in the second step. So in order to get the right number, I need to get it after the tween is finished. It works if I just put in a “wait for 2.1 seconds” and grab the value afterwards. However, this is not elegant at all. And since there is this specific condition for exactly this case, I want to utilize it.

Just removing the “trigger once” condition does not make any difference.

Do the tweens work otherwise? Are they making the changes even a little? Are there any other events or behaviors that could be modifying the object? Are there any errors in the debugger ?

The tweens work flawlessly, totally as expected. Since I just introduced this whole block (topic wise), I can rule out interference from unexpected directions.

The last entry I see in the debugger ist the info message that the variables have been initialised correctly (the block above the screenshotted area). Like I wrote, it seems that - for whatever reason - the condition is simply not met.

What’s the value of the object variable before the variable tween. The tween uses the existing value for the starting value. The tween won’t work if it’s a string. It will create it if it doesn’t exist but I don’t think it will do anything if the variable is a string.

As mentioned, a tween finished condition doesn’t need a trigger once if you delete the tween once it’s done. If the tween is repeated the variable would need to be reset to zero before the tween was added.

Regarding your first paragraph:

Value is -2, Blur 10 and Temp 0. Before tweening Temp, it gets set to a random int beetween 0 and 5.

This is literally all that happens on creation:

There is a doStepPreEvents part, but this only syncs an effect parameter and transforms Temp into Value which is between -2 and 3:

There is no additional interaction with other parts of the code at all (besides creating the instances).

What it does is it goes through the values (-2, -1, 0, 1, 2, 3) and slows down, kinda like a wheel of fortune (it simulates a die that’s being rolled). Obviously, I need the final value, hence I can only grab it after the tween is done.

Regarding your second paragraph:
I tried this:

However, the outcome is the same. The third block doesn’t get triggered at all.

The remove tween would be on the event with the tween finished It would need to finish first. It releases a few resources and prevents the finished condition from triggering.

The pre event. Is that one time or is it contious? If it’s continuous and the same variable that the tween uses then it might be interfering with the tween.

The remove tween would be on the event with the tween finished It would need to finish first.

Sorry, I seem to be on the fence. Do you mean like this?

The result is the same, the block doesn’t get executed.

The pre event is continuous, but it only reads Temp, the variable it actually sets doesn’t get tweened.

1 Like

That is the proper order. IDKW it’s not working.

It means that the event won’t trigger again because the tween doesn’t exist, and does away with the trigger once. It’s good programming practice.

Also it keeps it clean and less prone to errors. Having the same named tween called twice can lead to unexpected behaviour.

I understand what your issue is, but don’t understand why you’re getting it. All the events look fine, so I’m suggesting alternative ways of getting the outcome you’re after in case there’s a quirk under the hood of GDevelop that we’re not aware of.

Why are you using a trigger once by itself? If a “At the beginning of the scene” condition works just as well, could you try that instead?

Where is this block of code? The other code was a pre event. Is this a step or function? This is part of a behavior? I just want to make sure the condition is being checked on each frame not just a one time action.

The one caption says this is what happens on creation. Does that mean the is finished condition isn’t being continually checked?

1 Like

I just want to make sure the condition is being checked on each frame not just a one time action.

This was the hint! It worked with the wait command since it stayed within the “on creation” trigger. But the condition hasn’t been triggered again since it was checked directly after the tween started. I moved it the block to the doStepPreEvents part and it finally worked!

Thanks a lot @Keith_1357 and @MrMen for taking the time to figure this out! :pray: :heart: