Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

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.