# how to differentiate clones?

Hi!

I want to have my character with the input of "fire1" to instantiate around 5 flying daggers gameobjects(prefab) around him and then give them a x velocity, but each at a different time.

so forgive me since it would make this 2 questions.

``````//Insantiate a rigidbody then set the velocity
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);
}
}

``````

This is the code I got from the script reference. The first question is: how can I loop the instantiate part of the code to create the 5 projectiles. The second question is: once the 5 daggers are created, how do I point to them individually?

Or would it be easier to have each of the projectiles their own script that sets their velocity?

try this :

//Insantiate a rigidbody then set the velocity

``````var projectile : Rigidbody;
var velocities : Vector3[];

function Update () {

// Ctrl was pressed, launch a projectile

if (Input.GetButtonDown("Fire1")) {

// Instantiate the projectile at the position and rotation of this transform
for(i=0;i<velocities.length;i++){

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 (velocities*);*
*}*
*}*
*}*
*```*
*<p>so just fill out the array of velocity Vector3's and then it will clone as many as you say.</p>*``````