how to set the parent unity code example
Example 1: unity change parent in script
player.transform.parent = newParent.transform;
Example 2: unity set parent to root
gameObject.transform.parent = null;
player.transform.parent = newParent.transform;
gameObject.transform.parent = null;