홍의숙*_*홍의숙 2 c# angle rotation quaternions unity-game-engine
我正在努力用操纵杆旋转gameObject.操纵杆将json数据包含的角度值发送给gameObject.gameOjbect在接收Jsondata时应该自行旋转.但是,我想知道如何以角度(0到360度)旋转它,因为我所知道的是在下面使用(Vector3)位置.
Quaternion.LookRotation
public static Quaternion LookRotation(Vector3 forward,
Vector3 upwards = Vector3.up);
Run Code Online (Sandbox Code Playgroud)
总之,我想知道的是从角度旋转gameObject.
使用RotateAround.
// Rotate around world y.
transform.RotateAround(transform.position, Vector3.up, angle);
// Rotate around local y.
transform.RotateAround(transform.position, transform.up, angle);
Run Code Online (Sandbox Code Playgroud)
Transform无论如何,您可能会在文档中找到其他有用的东西
transform.eulerAngles = new Vector3(90, 0, 0);
Run Code Online (Sandbox Code Playgroud)
将游戏对象沿 x 轴旋转 90 度。
或者你可以平滑地旋转
Vector3 destination = new Vector3(90,0,0);
transform.eulerAngles = Vector3.Lerp(transform.rotation.eulerAngles,
destination,
Time.deltaTime);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14968 次 |
| 最近记录: |