📜  如何让对象在 curcle 中生成 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:51.751000             🧑  作者: Mango

代码示例1
for (int i = 0; i < numObjects; i++)
{
    float theta = i * 2 * Mathf.PI / numObjects;
    float x = Mathf.Sin(theta)*radius;
    float y = Mathf.Cos(theta)*radius;
  
    GameObject ob = new GameObject();
    ob.transform.parent = transform;
    ob.transform.position = new Vector3(x, y, 0);  
}