void die() { spawnOnTouch previousSpawn = otherSpawn.GetComponent <spawnOnTouch>(); previousSpawn.discard(); Destroy(previousSpawn.gameObject); }
void OnTriggerEnter(Collider other) { // If the colliding gameobject is the player if (other.gameObject == player && !isShowing) { isShowing = true; if (objectToSpawn != null) { myObject = Instantiate(objectToSpawn, location, Quaternion.Euler(new Vector3(0, 0, 0))); } if (otherSpawn != null) { spawnOnTouch previousSpawn = otherSpawn.GetComponent <spawnOnTouch>(); previousSpawn.discard(); Destroy(previousSpawn.gameObject); } SendMessage("onTouch"); } }