Well, you would want to use an instantiate function like this:
var prefab : Transform;
function Update () {
for (var i=0;i<10;i++) {
Instantiate (prefab, Vector3(i * 2.0, 0, 0), Quaternion.identity);
}
}
This creates 10 'a' prefabs two units apart from each other. Put this code on an empty gameobject, and see the results!
Another use for instantiate
is for guns, like this:
var projectile : Rigidbody;
function Update () {
// Ctrl was pressed, launch a projectile
if (Input.GetButtonDown("Fire1")) {
// Instantiate the projectile at the position and rotation of this transform
var clone : Rigidbody;
clone = Instantiate(projectile, transform.position, transform.rotation);
// Give the cloned object an initial velocity along the current
// object's Z axis
clone.velocity = transform.TransformDirection (Vector3.forward * 10);
}
}
Put this code on your camera, and you should be set to go. Hope this helps!