Unity Community

Results 1 to 3 of 3

  1. Posts

    Add a child to a game object in a script


    I'm just getting started with Unity, and it looks great so far. However, i'm struggling to do something that should be quite simple to do (it's prolly just me being a failure ) :

    Let's say I have a GameObject, called "Group" with a script assigned (or an instance of a prefab with just a script in it). What i want to do is to add a child to the Group (a child in the Hierarchy, not a Component) within my Start() function in the script.

    When i tried to use Instanciate() to create a new object in my scene, it just puts it at the root of the Hierarchy, couldn't find a way to add it as a child of Group.

    Any clues ?

    Thanks in advance,


  2. Location
    Latvia, Riga

    I'm new to Unity too and wanted to do the same thing. I stumbled upon this: http://unity3d.com/support/documenta...rm-parent.html

    I haven't tried it yet, since I'm not home, but it certainly looks like the right property.

    (that is, obj = Instantiate(); obj.transform.parent = parentTransform)

  3. Posts
    Aah cheers mate, it works Issue fixed !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts