Posts

How to instantiate a prefab as a child in Unity?

  The basic principle of attaching any object to a bone of your animated model, is to make that objects transform a child of the bones transform. For example: parent the hand bones transform to the swords transform. You  could  access the bones transform by script using weapon.transform.parent = GameObject.Find( path to your bone ).transform; but this is quite unflexible.  Instead  take a look at the following script, which you could add as a seperate component to your animated model. (you can of course implement the code in your own classes too): public var weapon:GameObject; public var weaponBone:Transform; function Start () { // instantiate the weapon prefab var weaponTransform:Transform = Instantiate(weapon, weaponBone.position, weaponBone.rotation) as Transform; // make the bone a parent of the weapon weaponTransform.parent = weaponBone; } Now you have to assign the bone of your animated model to the weaponBone variable. Find the bone in the Hierarch...