Ramesh Madara
Ramesh Madara

Reputation: 13

Create a copy of a child gameObject and have it still exist when the parent is deleted

I have implemented an instantiation spawn system into my endless runner game. I want to have a gameObject inside a parent gameOject to follow the player as far as it needs to and not disappear when the parent gameobject is called back in the pool.

I don't know if this is possible. If not, point me where to go

Upvotes: 0

Views: 447

Answers (1)

derHugo
derHugo

Reputation: 90714

Well, You could either simply detach the child from the parent before it gets destroyed by simply changing its Transform.parent

theChild.transform.parent = null; // or any other Transform

or you could create a clone of the child via Instantiate e.g

Instantiate(theChild, theChild.transform.position, theChild.transform.rotation);

Upvotes: 2

Related Questions