I have a circle and when I click it, a square appears.
When I click the square the circle should be destroyed.
There are two circles on the screen.
When I click the square, BOTH circles get destroyed.
I want only the circle that spawned the square to be destroyed.
How to do this?
Develop games in your browser. Powerful, performant & highly capable.
Save the uid of the circle in a variable of the squares.
On click of the square compare its variable= circle uid, circle destroy
I did this and it destroyed both circles again.
I found out that this destroyed all circles if the square is spawned from the circle that has the lowest UID.
Otherwise, nothing happens if it is spawned from other towers and clicked.
I tried several different things and nothing seems to work.
But what really did surprise me, was that this doesn't do anything at all:
(Notice I changed it to ID for the circle too, but doesn't change anything)
Man, this was so stupid. I can't believe this was the solution:
If someone can explain why this worked, it would be appreciated.
Anyway, this was bothering me on other games, so it would certainly help others.
System compare does not pick the instance.
You want to use things that do pick like compare uid, or compare variable.