hello, i’m trying to destroy a tagged object. i have tried many different ways. if i click on a tagged object, i want to destroy it. it seems simple but… the only one that worked (somewhat) without any errors were Destroy(gameObject)… unfortunately, that was my player. thanks for any advice.
#pragma strict
function Start ()
{
}
//var holdTagName = transform.tag("weapon");
function Update ()
{
if(Input.GetMouseButtonDown(1))
{
var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(ray,hit,4.0f))
{
if(hit.transform.tag == "weapon")
//if(other.gameObject.CompareTag("Player"))
{
Destroy(transform.tag);
//Destroy(transform.tag("weapon"));
//Destroy (other.gameObject);//Destroy(//(holdTagName);
// Destroy(gameObject); no errors, but destroys player
}
}
}
}