I’m using
RaycastHit vHit = new RaycastHit();
Ray vRay = camera.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(vRay,out vHit,50))
{
Debug.Log(vHit.collider.name+" deleted.");
Destroy(vHit.collider.gameObject);
}
to delete objects in game and it works fine until you miss the object and delete the terrain, and fall to your doom.
Is there a smarter way of filtering out the terrain object than just throwing in an extra if statement checking for the name at every click?