Search Unity

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.