call_group overrides following commands?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By 1izNoob

I am currently building a strategy game and try to implement the selection behaviour so that if the player clicks on a unit that unit is selected and any previously selected unit is deselected.

The setup is the following:

Unit scene → this one contains a unit and is part of a group, it also has a variable active that is used to trigger other behaviour to highlight it. Each unit also has a function to set active to false.

Main scene → The units are attached as children in here and this scene checks user input via _input and inside of that _input function the logic goes as follows:

1. I check if the left mouse button was pressed. 

2. If the mouse button was pressed, I call the group with the units and run the function that sets active to false for all of them.

3. Below the code for the group call I have another function that checks if the mouseposition was on top of a unit, and that unit gets active set to    true again. 

I feel like the logic is sound (or is it?) but somehow it is impossible to set any unit to active in this way. Am I making a mistake somewhere? If I remove the call_group part I can select units but units never get deselected though.

The logic sounds reasonable enough, but it’s difficult to provide much input without seeing the actual code…

jgodfrey | 2021-01-01 15:57