Selection logic

i’m trying to allow the user to “select” a turret by clicking on them, making the range indicator move to that turret’s position however i only want one turret to be selected at all times. I also want it so that whenever a new turret is being placed, that one is selected and that the user can unselect it by clicking on the selected turret base again. how should I approach this?


And you could use Else to hide it

sorry, i still couldnt figure it out :frowning:
i decided it would be easier for each turret to have its own range indicator and i just want to get it to hide and appear on click, but even that dont work

huh. for some reason its just not showing the RI after i click off the initial turret. i redid it to make it once and there aren’t any other extraneous hides.


do i have to use a different animation?

If you are not replicating exactly something someone showed you
Then don’t act surprised it does not work

Depends - will you ever need to select more than 1 turret at a time?

nah, thanks to the final change i guess it works now. it would be nice to deselect, but i’ll implement that later.

I think you need to use NOT instead of inverted.

Have a look here: Collision test - inverted and NOT

For this type of thing I find it much easier to use a selector object.

Since you probably already want a sprite that indicates which thing is selected, you can also use that as the link to the actual object. Instead of using conditions for the variable of the turret, you would just pick it from the selector. If the selection object is exactly the same size as the turret object then you can conveniently check the position… assuming turrets aren’t allowed to overlap the exact same position, you can just move the selector around and then check if turret position = selector position to get the appropriate turret.

Or, you can link them together. Just need to remember to unlink all turrets before linking a new one (otherwise you’ll just keep adding more links :slight_smile: )