gpt4 book ai didi

c# - unity 绕z轴旋转

转载 作者:太空宇宙 更新时间:2023-11-03 18:20:29 24 4
gpt4 key购买 nike

我试图在实例化对象时随机旋转对象。但是我很难只在 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;

最佳答案

currentcircle.transform.rotation = Quaternion.Euler(0.0, 0.0, Random.Range(0.0, 360.0);

或者

currentcircle.Rotate(0.0, 0.0, Random.Range(0.0, 360.0));

参见 Previous Answer

关于c# - unity 绕z轴旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57716631/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com