Game breaks when two instances do the same thing at the same time

Hello everyone,

Weeks working on this and trying to find solutions online and I just don’t know what to do. I’d really appreciate your help on this.

The loop I’d like to achieve:

  • NPC “Alien” arrives at the “station”
  • Once a Zone is open (purchased), one Alien goes to it and stays for a while before heading back out.
  • To do so, the NPC goes to the portal on the right, then goes down, to the zone, then to the other side and finally back up before heading to the green object where it gets deleted.


  • The game breaks, either the NPCs get stuck on the edge of the screen:
    Stuck edge

  • Or the timers are not started on Zones and they stay there forever.
    Stuck dead timers

What I figured out:
Narrowed down the problem to a conflict between instances being at the same event at the same exact time and it breaks the loop every time.


  • Using variables that are unique (based on a randomised ID number for each NPC at spawn)
  • Using For each object (tried several mix of Alien and Zone (The NPC and where it goes))
  • Using uniquely names timers too.
  • A series of subevents starting with the selection of the Alien and the Zone to keep the whole loop tied to one event but that didn’t work at all for me.

Here’s a link to the “game” (that’s a very generous name for my current broken loop lol). If you click on the “Plus signs” (3 of them, one for each “zone”), it will activate the loop. Made the NPCs much much faster to get to the breaking points faster too.

The event sheet: (Apologies for the mess, most likely cluttered the whole thing more than it needs to be but… desperate noob here trying things left and right)

Thank you very much for your time and hopefully some guidance on the many things I’m sure I did wrong.


I admit it was too long to read.

The logic is a bit backwards. You want to use shared conditions first and then use a for each object as a sub-event. Conditions work like filters. You want to reduce the object pick list before using a for each object so it only loops through the minimum number of objects.

Say you had apples. You would first pick the apples that were red and then use a for each object to do something depending on their size.

It’s the difference of looping 100 times for 100 objects or looping just 20 times for the 20 out of 100 red apples. Or maybe not looping at all if there are zero red apples.

Another issue is the trigger once inside a loop. Trigger once works on an object level and doesn’t work as expected in a loop. If needed, it’s better to use another condition or an object variable to prevent multiple triggers at an instance level. Object booleans are your friend.

A lot of time an action will change things so the original condition won’t still be true in the next frame. Like if you check if an object is visible and hide it. On the next frame it would be hidden and the condition would be false. So, a trigger once wouldn’t be needed.

I’ll look through your events again later but I think your problem would clear up if you remove the trigger once events and only add another variable or another condition if absolutely necessary.

There are also times when a for each object might not even be needed for example when all of the objects are using the same action. You can delete them one at a time or delete them all with one action. I’m not saying that applies here. But it’s always a good idea to limit the number of loops and if too intensive then also their frequency.

1 Like

Apologies for the heavy novel above, I appreciate you took the time to help Keith, as always. I’ll try and rewrite the code following your suggestions. Many thanks !

1 Like

No apologies needed. I’m glad to look at your events. In this case, I think it’s the trigger onces and it would be better to reorganize things first. I’ll be happy to help you afterwards. I think you’ll see how much easier things are to read and follow. Good luck.

1 Like

As a way to understand your process and create an example, I decided to try to recreate your project although I’m not sure I followed your process but I think it’s close. Using linking would eliminate the need for an ID. I think tweens might be easier or maybe using a navigation setup where an alien moves from nav point objects with indexes. This still seems overcomplicated unless I’m not fully understanding your sequence of events.


Try me (It runs by itself. There aren’t any interactions.

1 Like

Hi Keith,

You are trully incredible. I was already quite grateful for you pointing out the errors of my ways but I never suspected you’d actually write the whole thing yourself. This is equally amazing and frustrating to see how fast this comes to you when I spent weeks on this and it still doesn’t work as intended lol.

I didn’t know about Linked object but I suppose I could have done without. Extremely helpful though, thank you for that too.

I don’t understand this: “moves from nav point objects with indexes”

The current set up is supposed to be scalable, adding more floors of three stations as the game progresses. At some point I was contemplating using pathfinding behaviour and obstacles to let the NPC reach the zone the fastest way it can. Not sure if that would have made things easier.

I’ll try first to rewrite my own version and if (when…?) I get stuck, I’ll study your example to improve my work.

I’m still not quite sure what would make two instances conflict between each other and break the loop but I suppose it’ll just work better if written properly (BIG DUH!).

Thanks again Keith.

It was this, for sure. When I started, I didn’t know of them and they were taught to me and really saved my ass at times and I guess I’ve been overusing them without understanding how limiting they were for other scenarios. Learned tons, thanks to you.

I think it’s the trigger once especially inside loops. The thing with trigger once and instances is once the condition are true it won’t trigger again until the condition is false and true again.

Conditions do 2 things. They return true and false and if true they pick the objects.

Object Variable count = 7
Trigger once

As soon a one object’s count variable is 7 it triggers the action but with the trigger once it won’t trigger again no matter how many other instances variable equals 7. It won’t trigger again until all instances variables are not 7 and then again, it will only take 1 object to trigger the actions and start the process all over again.

This still confuses me at times. I’ll make test projects just to try to get a better understanding.

The nav idea was using an ID variable on an object. Number the instances like navigation points. Then move from instance to instance using a tween. The multiple zones and the pause might be tough.

Using the pathfinder with obstacles would be easier. One path down and one path back.

I enjoy a challenge. I enjoyed this. I don’t fully understand your bigger picture but I like the concept. I’ve played with the waiting in line concept before.

I’m not sure if there are any examples in my github. You’re free to check. There’s a link in my profile. GitHub

I find it easier to explain some concepts through a project.

1 Like