public GameObject Child;
public Transform NewParent;
// Sets "newParent" as the new parent of the child GameObject.
Child.transform.SetParent(NewParent);
// Removes parent, puts child into a top-level object in the hierarchy
Child.transform.SetParent(null);
childObject.transform.parent.gameObject
// To get the parent object:
childObject.transform.parent.gameObject
public gameobject player
public gameobject Newparent
player.transform.parent = newParent.transform;
void OnCollisionEnter(Collision collision)
{
PlayerController pl = collision.gameObject.GetComponentInParent<PlayerController>();
}
public GameObject Child;
public Transform NewParent;
// Sets "newParent" as the new parent of the child GameObject.
Child.transform.SetParent(NewParent);
// Removes parent, puts child into a top-level object in the hierarchy
Child.transform.SetParent(null);
childObject.transform.parent.gameObject
// To get the parent object:
childObject.transform.parent.gameObject
public gameobject player
public gameobject Newparent
player.transform.parent = newParent.transform;
void OnCollisionEnter(Collision collision)
{
PlayerController pl = collision.gameObject.GetComponentInParent<PlayerController>();
}