Instantiate array object to initial position ..

Hi!!

I want to clone objects but using the initial position of gameObjectEmpty, the problem is that I also want to clone objects in a cylindrical array.

var numberOfObjects = 5;
var radius = 5;
var nameToClone : String;
var positionClone : Transform;

function Start () {

var obj : GameObject = gameObject.Find(nameToClone);


    for (var i = 0; i < numberOfObjects; i++) {
        var angle = i * Mathf.PI * 2 / numberOfObjects;
        var distance = i * 30;
        
        var pos = Vector3 ( Mathf.Cos(angle), 0,  Mathf.Sin(angle)) * radius;
        Instantiate(obj, pos, Quaternion.identity);
    }
}

Thank for all :slight_smile:

Hi pierrebix ,
Good try,

Use this statement.

var pos = ( Vector3 ( Mathf.Cos(angle), 0, Mathf.Sin(angle)) * radius ) + obj.transform.position;

That’s all folks !!! :wink:

Hi!!
thank !!:slight_smile: