- Home /
instantiating Transform insted of PrimativeType
i got this script from a friend and im wondering if its possible to insted of using PrimitiveType to use a Transform.
script:
for (var y = -4; y < 100; ++y)
for (var x = -4; x < 100; ++x) {
var cube : GameObject = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.transform.position = transform.position + Vector3(x, -3, y);
}
Answer by aldonaletto · Oct 23, 2011 at 01:09 AM
I you want to instantiate any object instead of just the primitive types, use Instantiate:
var source: Transform; // drag the source object here in the Inspector
for (...){ for (...){ var clone: Transform = Instantiate(source); clone.position = transform.position + Vector3(x, -3, y); } }
Your answer
![](https://koobas.hobune.stream/wayback/20220613020331im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Problem when manually creating game object in scene 3 Answers
Moving an Object along a Bezier Curve 3 Answers
Scaling width/height of a character's head/body 5 Answers
Instantiating a new gameObject as a child of a different gameObject 2 Answers
Cache a lot of object transforms in a builtin array? (iPhone) 1 Answer