Answers for "instantiate object in circle"

C#
0

instantiate object in circle

float radius = 1f;
 int amountToSpawn;
 for (int i = 0; i < amountToSpawn; i++)
 {
     float angle = i * Mathf.PI*2f / amountToSpawn;
     Vector3 newPos = new Vector3(Mathf.Cos(angle)*radius, y, Mathf.Sin(angle)*radius);
     GameObject go = Instantiate(GameObject.CreatePrimitive(PrimitiveType.Cube), newPos, Quaternion.identity);
 }
Posted by: Guest on June-14-2020

Code answers related to "instantiate object in circle"

C# Answers by Framework

Browse Popular Code Answers by Language