I have a script that deletes an object that is called a certain name “Object 1” when it is clicked. I have the script attached to all of my gameobjects and it works fine. I can click every other object and it doesn’t trigger the deletion. As soon as I click the object that should be deleted, it deletes ALL of my other objects with the script attached. Here is my code for deletion:
if(Box.collider.gameObject.name == "DeleteMe")
{
Destroy(this.gameObject);
}
else
{
}
I have tried using this.gameObject and just gameObject, it still deletes all objects with the script attached to. I’m using c#, if anyone could help it would be great thanks. I’m new to unity so excuse if I’ve made a stupid error!