More linking issues

I’m having issues with my “enemyLight” objects. The enemyLightLeft object is fine as seen in the video but the enemyLightRight object is I guess linked to all patrols that are spawned before it (The first spawned patrol is at the top and patrol to be spawned last is at the bottom).
Here is the video of the problem: https://drive.google.com/file/d/1hm5HdSC7uK3e39617mugjM7vcV-Z-Euz/view?usp=sharing

code pictures:


DO NOT take me as expert in linking
What you see below is just what i concluded via trail and error
Try to apply it to your events

This is more complicated to say then it sounds but it’s a fundamental concept that took me awhile to understand. So, I want to explain it the best that I can.

Each event group is picking either the left or right light but when it’s picking the patrol that is linked to the light group, the group contains the collided light plus all of the lights for the the other side . So, when it tries to pick the linked patrol it’s going to use the object in the light group. It can only use 1 object so it uses the object from the light group whose name was added to the group first it then uses the oldest instance in that light.

To fix it use the light name instead of the light group name when picking the linked patrol and then use the other light name to pick the other light that is linked to the patrol.

Here’s how I tested it.

One last time. This is your current setup.
You start with say 3 patrol objects and 3 of each light.
The player collides with a left light
The light group contains the left light and all of the right lights
You then pick the patrol linked to the light group
The issue is thel light group has left and right lights.
GDevelop will use the light in the light group that was added first to the light group.
So, it might use the left light of the oldest right light.

My way.
Player collides with left light
Pick the patrol linked to the left light
Pick the right light that is linked to the patrol

Reverse it for the right light.
Player collides with right
Pick patrol linked to right
Pick left linked to patrol

One light is already picked. So, you just need to pick the patrol and the other light.

1 Like

Thank you so much! This worked perfectly. Awesome sauce.

1 Like