I’m trying to apply different animations for each instances. Basically, my event looks like this:
For Each instance of "enemy"
Condition:
Variable 'enemy_id' of "enemy" >0
Trigger Once
Action:
Change the number of animation of "enemy" set to:RandomInRange(1,3)
I expect for each instances to get a random animation once. However, the Trigger Once seems to only apply to the first instance (despite each of my “enemy” instances having different ‘enemy_id’ variable).
Is there any alternative(s) to do this correctly or I’m messing up something here? Even tried switching to sub-event, reordering conditions/actions and still don’t get the result I hope for.
As MrMen mebtioned, trigger once in a for each behaves as a computer would expect, only once (meaning the first object instance that meets the conditions only), even though that doesn’t match up with what you or I would first expect.
The linked thread does provide more details and alternatives.
Thank you! It now works after following your logic now. Here’s what I changed:
I replaced the Trigger Once condition with: The number of animation of "enemies" =0
I have to add an empty animation #0 in the “enemy” object’s animation. So that each enemy instance with animation #0 will change randomly in range 1 to 3. That’s my solution for now.