- Home /
Question by
unity_18DD2BC61264757EC5F5 · Jan 28 at 07:25 PM ·
instantiateparentproblema
Instanitate an object inside a parent with no errors or gameobject error
So i ran onto this problem And i can't seem to know how to fix it.
I Want It To Instantiate Into A Parent Without GameObject Errors Like Having The GameObject Put In A Different GameObject Than What I Needed.
GameObject gameobj;
void Start()
{
Instantiate(gameobj);
// make it inside a parent
//not run into gameobject errors
//can be repeated
}
im sorry if this is too much im a bit beginner in these things. thanks Zuku
Comment
Answer by UnityPlum · Jan 28 at 09:45 PM
public void InstantiateObjectInParent (GameObject prefab, GameObject parent){
GameObject instance = Instantiate (prefab);
instance.transform.parent = parent.transform;
}
Your answer
Follow this Question
Related Questions
OnTriggerEnter - check if collider is child 1 Answer
Instantiating prefabs as child of a gameobject 1 Answer
Manipulating Instanced Object 2 Answers
Parenting GameObjects 1 Answer
Instantiating a group of 8 objects, or 8 individually? 1 Answer