Search Unity

Help with unparenting a single object

Discussion in 'Scripting' started by slingy11, Jan 22, 2014.

  1. slingy11

    slingy11

    Joined:
    Jun 8, 2013
    Posts:
    8
    I'm making a game, and I have a bunch of objects with mesh colliders parented under an empty object. The empty has a Rigidbody on it as well. How do I unparent one of those objects with mesh colliders from the parent and add a Rigidbody to that object from the object's code? I'd prefer it to be in C#, but I can translate from Javascript.
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can set the object's transform.parent to null.

    --Eric
     
  3. slingy11

    slingy11

    Joined:
    Jun 8, 2013
    Posts:
    8
    That won't work for me.
     
  4. slingy11

    slingy11

    Joined:
    Jun 8, 2013
    Posts:
    8
    Nevermind, I was using the OnCollisionEnter function from each part.