Hello, I was developing one of my systems i am currently working on and i stumbled uppon a problem. My goal is that when everything is spawned as a child, to put them into a circular shape. But what happens is that every child rotate around its own axis and just turns.
Why don’t you apply this when instantiating you may ask? Well my system does allot of calculations and positioning before and that information is crucial for the system to work, that is why this piece of code is executed afterwards when all is done.
function Cilinderizer(){
//total amount of childs that will be there
var shaftCount:int=ShaftRowX*ShaftRowY*ShaftRowZ;
var i:int=0;
var children = GetComponentsInChildren (Transform);
for (var child : Transform in children) {
i++ ;
var angle = i * Mathf.PI * 2 /shaftCount;
var pos = Vector3 (Mathf.Cos(angle),Mathf.Sin(angle),0) * CylinderRadius;
child.localPosition=pos;
}
}
Did I make a mistake or is it something else? I am not using a for loop such as for(var i :int; etc,ect){} Because the loop already iterates trough all the children needed.

What are your values for shaftCount and CylinderRadius?
– flaviusxviishaftCount are 3 int values in the inspector wich are added together (count1+count2+count3=shaftCount), CylinderRadius is also a value in the inspector, normally this should determine how big the circle will become.
– MarkDNot their life story.. the actual values at runtime.
– flaviusxviiCount1=20,count2=20,count3=1. CylinderRadius=10 EDIT on last coment i said they add up, but the count values are multiplied on each other.
– MarkDAre you getting 'angle' values that you expect. Have you put a Debug.Log(pos) at the end of the loop to see if you are generating good positions?
– flaviusxvii