private Vector3 GetChildPosition(GroupRotatingPillar child, float radius) { return(new Vector3( radius * Mathf.Cos(child.angleFromGroupCentre * Mathf.Deg2Rad), 0f, radius * Mathf.Sin(child.angleFromGroupCentre * Mathf.Deg2Rad) )); }
/** * Identify where the children of the group should be in relation to the centre based on the radius and put them there. */ public void InitialiseAndPositionGroup(float radius) { Debug.Log("Group Children: " + transform.childCount); groupCentre = GetComponent <RotatingPillar>(); for (int childIndex = 0; childIndex < transform.childCount; childIndex++) { //Get the RotatingPillar component from the child, skip it if it doesn't have one. GroupRotatingPillar pillar = transform.GetChild(childIndex).GetComponent <GroupRotatingPillar>(); if (pillar == null) { continue; } outerPillarsCorrectPosition.Add(pillar, pillar.transform.localPosition); pillar.transform.localPosition = GetChildPosition(pillar, radius); } }