unity 绕 z 轴旋转

Kei*_*wer 1 c# unity-game-engine

我正在尝试在实例化对象时随机旋转对象。但是我很难只在 z 轴上旋转。

GameObject currentcicrle = (GameObject)Instantiate (circlePointPrefab);//instaiate object
currentcicrle.transform.parent = parent;
currentcicrle.GetComponent<Renderer>().material = currentLineRender.GetComponent<LineRendererAttributes> ().material;
currentcicrle.transform.position = position;

currentcicrle.transform.rotation = Random.rotation;
Run Code Online (Sandbox Code Playgroud)

Eri*_*ton 6

currentcircle.transform.rotation = Quaternion.Euler(0.0, 0.0, Random.Range(0.0, 360.0);
Run Code Online (Sandbox Code Playgroud)

或者

currentcircle.Rotate(0.0, 0.0, Random.Range(0.0, 360.0));
Run Code Online (Sandbox Code Playgroud)

见上一个答案