public void ReassignObjectGhost(PlaceableObject obj) { foreach (Transform child in objectGhost.transform) { GameObject.Destroy(child.gameObject); } ObjectGhost newGhost = Instantiate(obj.GetGhost().GetComponent <ObjectGhost>()); newGhost.transform.SetParent(objectGhost.transform); newGhost.transform.position = objectGhost.transform.position; newGhost.transform.rotation = objectGhost.transform.rotation; newGhost.gameObject.SetActive(true); }
void OnTriggerEnter2D(Collider2D other) { if(other.tag == "Player"){ //Destroy (other.gameObject); //Application.LoadLevel(Application.loadedLevelName); ghost = other.GetComponent<ObjectGhost>(); ghost.Reset(); return; } if(other.gameObject.transform.parent){ //destroy the parent object Destroy (other.gameObject.transform.parent.gameObject); }else{ //destroy the object Destroy (other.gameObject); } }