Bacteria/Cell Growth

Hi there,

I am trying to code some basic bacterial growth into unity. I would each clone of my capsule to appear from the position of the clone that created it. However, at the moment all of my clones are simply appearing from the original clone. Here is the script I am using at the moment.

#pragma strict

var cube: GameObject;
var spawn_position;
var timer = 0.0; 

function spawn_cube ()
{
spawn_position = cube.transform.position;
var temp_spawn_cube = Instantiate(cube, spawn_position, Quaternion.identity);
}

function Start () {

}

function Update () {
timer += Time.deltaTime;
if (timer > 10)
{
spawn_cube();
timer = 0.0;
}
}

Any help would be much appreciated!

Thanks very much :slight_smile:

Something like this?

function spawn_cube ()
{
    spawn_position = cube.transform.position;
    var clone = (GameObject) Instantiate(cube, spawn_position, Quaternion.identity);
    var cloneScript = clone.GetComponent.<Bacteria>(); // Whatever your script is called.
    cloneScript.cube = gameObject; // Make it clone from me
}