如何根据角度旋转对象?

How can I rotate an object based on an angle?

我在 Unity3D 中工作,我想知道如何根据立方体和鼠标位置之间的角度旋转立方体。我的意思不是鼠标在世界中的位置 space 而是以像素为单位。

以下是一些可以引导您找到答案的页面:

Input.mousePosition This also includes an example of how to turn screen coordinates into a ray in world coordinates. If you know how far away from the camera you want your point, check out ScreenToWorldPoint 表示点而不是射线。

transform.Rotate执行旋转。

你的问题的其余部分有点含糊——旋转 "based on" 立方体和鼠标位置之间的角度可能意味着很多事情。不过,您应该不需要比这更多的信息了![=​​14=]