- Home /
This question was
closed Feb 21, 2013 at 03:44 AM by
sona.viswam for the following reason:
The question is answered, right answer was accepted
Question by
sona.viswam · Feb 20, 2013 at 04:26 AM ·
transformparentchildrenfind
Make into child of a parent in c#
GameObject mainpumkinclone = (GameObject)Instantiate(pumkin,
floorPosition + new Vector3(x, y, z), Quaternion.identity);
mainpumkinclone.transform.parent = transform.Find("prickle" + i);
This is my code but mainpumkincloneis not become a child of a specific prickle.
Please help to solve this issue.
thanks in advance.
Comment
$$anonymous$$ake sure transform.Find
returns a transform and not null. To do so, Debug.Log()
the outcome
Debug.Log(transform.Find("prickle" + i)); this shows null.
Then your not finding the right transform! You can set it fine, your just not finding it. Read the API on transform.Find
and see if your calling it right, or if your using the wrong function?
Best Answer
Answer by sona.viswam · Feb 20, 2013 at 06:07 AM
mainpumkinclone.transform.parent = GameObject.Find("prickle" + i).transform;
works fine.