- Home /
Question by
awplays49 · Mar 31, 2015 at 09:33 PM ·
rigidbodyinstantiate
How do I use = Instantiate on a non-rigidbody game object?
Usually for instantiating something you want the change after,
you'd do
Rigidbody r;
r = Instantiate (object, position, rotation);
r.transform.position += 1;
and what if something doesnt have a rigidbody?
Comment
Best Answer
Answer by _joe_ · Mar 31, 2015 at 09:37 PM
that's not really true.
Instantiate takes an Object and returns an Object so you can get the GameObject, Transform, Rigidbody or any component from it:
GameObject myGameObject = Instantiate(object, position, rotation) as GameObject;
myGameObject.name = "New Name";
myGameObject.transform = new Vector3(0,0,0);
myGameObject.GetComponent<customScript>().variable = 10;
Your answer
