- Home /
Solved it differently
How do I detect if there's an object at the same position and destroy ONLY ONE of them?
Detecting if there's another one is easy - simply use raycast or triggers.
But now I want to destroy only one of them.
If I just use Destroy(collider.gameObject) etc. it will ultimately destroy both...
Any ideas?
Dude... I was writing such a detailed answer to the last question you last asked only to see it gone for ever when I pressed submit, replaced with a Page Not Found image. Brutal.
What do you mean destroying only one of them? weren't you trying to detect if there was a tile already there so you wouldn't spawn 2 things on top of each other in the first place?
Answer by Akusan · Sep 10, 2017 at 03:37 PM
Add a boolean condition to check if 2 of the game objects exists. Then add the destroy function that only triggers if there are 2 objects and make sure that there is no object destruction if only 1 of the object exists.