Object/Instance selection

Hi all.

I have an object with several instances on the game scene set up as a board game. Each object instance has a set of variables, like ID which get a different number. What I’m trying to do is click on a specific instance and change the animation of other specific instances, like displaying valid moves. Unfortunately, the mouse over event selects a specific instance and then while trying to use “Repeat for each instance” event while checking the value of the variable ID, in order to get the proper ones, I don’t get any results. I understand that the “mouse over” does a smart selection on the instances but how can I refer to the rest of the instances and modify them? Should this be handled by a different even not under the “mouse over” event when a flag is set?

Thank you,

you can change a variable of the object that you hover over to a different one.
then have a separate event targeting all your objects that do not have there variable changed.
like variable selected. if cursor is on object change variable selected to 1.
in a different event, pick all objects with variable selected = 0 and change animation.

if you want to use it under certain circumstances, you can use a variable as bridge.
if cursor is on object, change variable selected to 1 and change scene variable select to 1
other event
if scene variable select =1
pick all objects with variable selected =0 do change animation.

Hi Slash. I was actually afraid of that, that I will need to use a variable as a flag since the ‘smart’ object selection is limiting my list of objects to the one taking place in the initial even trigger. It doesn’t sound bad to me, but I wanted to make sure it’s the proper way to do it in GDevelop.

Thank you,

you can try the event pick all.
im not sure if this will reset your previous conditions or not. worth a try.
otherwise a bridge variable is the way to go.

I once used an OR condition to reset the instance selection, it has this magical property :sweat_smile: but it’s kinda dirty.
Maybe Pick all will work, but the variable way seems much cleaner.

I tried the pick all event but it seems it was picking only the previously selected instances. A bridge variable maybe the way to do it.

I’m trying to do a simple boardgame (halma type) with a single movement to free attached squares and it works great so far. The problem is when I do a jump over an enemy paw in which case I need to pick the square sprite too land and also pick the square pawn I did the jump over. Does it make any sense?

1 Like