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

Set object as children.

Discussion in 'Scripting' started by Noah492, Aug 29, 2015.

  1. Noah492

    Noah492

    Joined:
    Jul 2, 2014
    Posts:
    44
    I have a gravity gun like script called Rigidbody Pickup. When I grab an object and look straight down I can have the object under me and repeatedly jump on it and go infinitely high into the air. Is there a way to set an object to be a child until it is thrown or released so gravity can affect the player and the object?
     
  2. Lethn

    Lethn

    Joined:
    May 18, 2015
    Posts:
    1,583
    Have you tried increasing the mass of the object in the inspector? It may be because whatever you're using as your player is heavier than the object itself.
     
  3. georetro

    georetro

    Joined:
    Jan 18, 2013
    Posts:
    218
    Use transform.parent if you want to make something become a child of a parent. For example:

    Code (csharp):
    1. newChild.transform.parent = newParent.transform;
     
    Kiwasi likes this.