unity畫圓

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

//利用球畫圓
public class NewBehaviourScript1 : MonoBehaviour {

    public GameObject sphere;

	// Use this for initialization
	void Start () {
        Debug.Log(Mathf.Sin(Mathf.PI / 6));//正確用法
        int count = 9;//每四分之一段數
        int radius = 1;//半徑
        for (int i = 0; i <= count; i++)
        {
            GameObject go = Instantiate(sphere);
           go.transform.position = new Vector3(Mathf.Cos(Mathf.PI/2/count*i), Mathf.Sin(Mathf.PI / 2 / count * i), 0)* radius;
            GameObject go1 = Instantiate(sphere);
            go1.transform.position = new Vector3(-Mathf.Cos(Mathf.PI / 2 / count * i), Mathf.Sin(Mathf.PI / 2 / count * i), 0) * radius;
            GameObject go2 = Instantiate(sphere);
            go2.transform.position = new Vector3(Mathf.Cos(Mathf.PI / 2 / count * i), -Mathf.Sin(Mathf.PI / 2 / count * i), 0) * radius;
            GameObject go3 = Instantiate(sphere);
            go3.transform.position = new Vector3(-Mathf.Cos(Mathf.PI / 2 / count * i), -Mathf.Sin(Mathf.PI / 2 / count * i), 0) * radius;
        }

    }
	
	// Update is called once per frame
	void Update () {
		
	}
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章