Quantcast
Channel: Questions in topic: "detach"
Viewing all articles
Browse latest Browse all 82

transform.DetachChildren() is deactivating my children's scripts after detaching from the parent

$
0
0
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().enemyContainer.transform; //childT.GetComponent().currentHealth = 0; //childT.parent = null; } //transform.DetachChildren(); deactivates the scripts }

Viewing all articles
Browse latest Browse all 82

Latest Images

Trending Articles





Latest Images