Removing 1 instance of an object

Hi,i’m a noob and trying to create a tower defence game.

My problem is… I want to be able to sell or upgrade the selected tower.

I cant figure out how to identify which tower should be deleted. Currently the action to delete a tower deletes all towers.

I have tried giving each tower its own UID but i read in another post that this is not the best way to do this.

Thanks in advance for your help :slight_smile:

Actually giving tower ID is best way since then you have ID for each tower which would make them like separate objects IF you check ID in condition before doing anything to tower

Other method
You said SELECTED tower
How do you select tower?
Because if you could select single tower then you would only delete the one that is selected
And ignore not selected ones

Yet another method
There is extension called RTSUnitSelection
Which allows you to select objects and do something only to ones that are selected
2023-09-09_04_24_422RjrT4ac_GDevelop

This selection marker is something i made it does not come with the extension
But i am using condition
Object is selected
To determine to which object give that marker
Which i select by just clicking on them

For you to check it easily which objects are selected
You could do same as i did here
Where i change tint of selected object

Simple condition
Object is selected

Action tint object to green

And object is NOT selected (inverted condition)

Action tint object to white (which gives it back original colors)

2023-08-19_18_04_QBY31oT544_GDevelop

So just by using tint action you would see if object is selected or not

And using selected condition
You could to which object (tower in your case) you wanna do something in actions

2 Likes

Thank you Mr Zero.

Im selecting the object through a mouse click, then an upgrade/delet menu is displayed. But that menu buttons arent linked to the tower. So when i press delete. It deletes all the towers!

Use boolean variables.

Object was clicked + menu is not already open = Change the boolean variable pick_me of Tower set to true

Menu was closed = Change the boolean variable pick_me of Tower set to false (would pick all towers, but that is intended)

The conditions of “menu is open/menu was closed” is up to you, since you created the system I suppose you already know the conditions that you will use to check it.

1 Like