Tween does not bind to a specific object

If I’m not mistaken, when we add the Tween behavior to an object and give it an ID, then we can just wait for the animation to end and execute the code (similar to timers). But it doesn’t work, because the identifier is checked not for a specific object, but for everyone. For a specific identifier to be processed, it must be unique.

My task was that when object 1 was created, animation A would fire. At its completion, object 2 would be created and animation B would fire. At the end of each animation, the object is deleted. As a result, I was able to achieve this with such a construction:
image

You have to check all objects to check the end of the unique identifier.
I suppose it should be simpler and work like timers.

Project: BugReport.zip

Hmm… You say something, but your example says something else.

Maybe I’ll state the obvious, but: ID is not a real object property, it’s just a name given to a variable.
If you don’t assign that ID to each instance, they all have an ID value of 0, because it’s just a variable like any other.


So without that edit of mine, your tween condition is actually “Yellow_0” in all cases.
So no, you don’t need a unique identifier for the tweens.

My example shows how difficult it is to finish animation completion events for dynamically created objects (when they are created several at once). I figured it should be easier (as I wrote, as with timers):
image

I still don’t understand what you’re trying to say.
How are timer conditions “easier” than tween conditions? In both cases, you use the condition with an instance variable to make sure that only the desired instance is targeted.
Did you understand what I wrote about that ID variable? :thinking:

Yes, I understand about the ID.
With the timer, it turns out that you need to name it and without any loops just wait for the instance to pass it and the code will be executed. In the case of Tween, it is necessary to loop through all instances and check for each of its completion. At first I thought that the identifier should be added unique, but since the ID is not automatically assigned, it turns out there is no need for this.

I’m actually going to bring this back up. It seems like Tweens don’t like working on multiple instances at all, even with a unique tween name and using “For Each”.

Here’s an example (These are the only events in the test project):

This event should basically give each GoldStar a unique tween of TweenName100, 333, 4000, etc.

However, when testing it, only the first instance works. each additional stays in place. The tween name gets updated correctly, but the speed variable is not increased.

Here’s the online preview:
https://game-previews.gdevelop-app.com/1619709352558-682393/index.html

1 Like

The Trigger once is spent on the first frame, and never gets invalidated, so further instances don’t benefit from it.
Replace it with a variable check, likeso:

Yep, this is related to Trigger Once behaving differently than most people expect in ForEach. Tristan has an issue opened on it: TriggerOnce should apply individually to each instance when used in a ForEach loop · Issue #2591 · 4ian/GDevelop · GitHub

These events work:

https://game-previews.gdevelop-app.com/1619736925372-797087/index.html