So lets say I have parent and a child object, and the moment you destroy the child object how would i instatiate and object on the parent object that would also be destroyed. I know if you do something like this you destroy the object
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Child Object")
{
Destroy(collision.gameObject); // for the child object
Instantiate(newObject, transform.position, transform.rotation);
// This works and I can Instantiate a new gameobject in its current position while destroying the old one.
Destroy(GameObject.FindWithTag("ParentObject")); // for the parent object
Instantiate(newOtherObject, transform.position, transform.rotation);
// This DOES NOT works and I cant Instantiate a new gameobject in its current destroyed place- BUT WILL APPEAR in the child's object place of origin where it was destroyed.
}
}
So how would I be able to do that, I know how to instantiate a new object when the Child is destroyed, but I would I really like to know is when I destroy the parent object for it to be able to instantiate a new object in its place in the same location that it was destroyed in? I would like to call it up by the FindWithTag if possible, if not any help to do it another way is also welcomed.
Thanks again.