I’m using transform.DetachChildren() in the OnDestroy() method to have my children be unaffected by the destruction of the parent game object.
The problem I have is:
transform.DetachChildren() is deactivating my children’s scripts after detaching from the parent.
is there a way to have my children that are detached to remain active after detaching them from their parent.
private void OnDestroy()
{
foreach (Transform childT in transform)
{
childT.parent = FindObjectOfType<GameManager>().enemyContainer.transform;
//childT.GetComponent<Health>().currentHealth = 0;
//childT.parent = null;
}
//transform.DetachChildren(); deactivates the scripts
}