Hi,
I have no idea what is going on in this small script, the other.gameobject wont destroy if its in a IF statement but if I put it in the open ontriggerenter it will destroy but then it destroy generally all triggers… I’ve been puzzled over this for 2 days. anyone know what am I doing wrong? Thanks.
void OnTriggerEnter(Collider other)
{
bool kill = false;
int layerNum = other.gameObject.layer;
if (layerNum == 14)
{
kill = true;
temp = elemnts[other.tag];
GameObject fx = (GameObject)Instantiate(temp, other.transform.position, Quaternion.Euler(0, 0, 0));
fx.transform.parent = this.transform;
}
if (kill)
{
Debug.Log(“inKill”);//however this is called
Destroy(other.gameObject);//this wont work
}
}