- Home /
invoke a prefab as child
invoke a prefab as a child, I need all the objects are invoked inside an empty object. please, this my code
using UnityEngine;
using System.Collections;
public class Invoker : MonoBehaviour {
public GameObject Objeto;
// Use this for initialization
void Start () {
for (int Q=0; Q<10; Q++) {
Instantiate (Objeto, transform.position+=new Vector3(0,-0.35f,0), transform.rotation);
}
}
}
Comment
i am guessing you need all your clones to be a child of a parent. this might help http://docs.unity3d.com/ScriptReference/Transform-parent.html
Answer by popuppirate · Nov 06, 2014 at 12:43 PM
Hi matey!
I was actually doing this the other day, funnily enough. Off the top of my head, it went a little like this:
void Somefunction(){
GameObject object_o= Instantiate (Objecto, transform.position+=new Vector3 (0f, -0.35f,0f), transform.rotation) as GameObject;
object_o.transform.parent=this.transform;
}
I hope this helps!
Cheers,
Popuppirate
Your answer
![](https://koobas.hobune.stream/wayback/20220613170815im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Error: 'transform' is not a member of 'Object' 2 Answers
Paint textures on an object 0 Answers
[Edited]-Android-swap position on touch 1 Answer
PC Input to Android 0 Answers
Android Object Drag With Touch Problem 0 Answers