Im trying to instantiate object as child of child.
I got this hierarchy
Player root - body - legPoint
Script on the Player and i need to instantiate as legPoint child. All i got for now - instantiating as body child this way
public class robotBody : MonoBehaviour
{
GameObject leg1;
GameObject leg2;
public Transform legPoint;
void Start ()
{
leg1= (GameObject)(Resources.Load("leg1"));
leg2 = (GameObject)(Resources.Load("leg2"));
}
void Update ()
{
if (Input.GetKey(KeyCode.Alpha1))
(Instantiate(leg1, legPoint.transform.position,
``Quaternion.identity) as GameObject).transform.parent = legPoint.parent;
}
}
this is my hierarchy, i need to instantiate it attached to LegPoint, but works only if im trying to instantiate it to summonPoint.