【发布时间】:2017-12-23 14:06:35
【问题描述】:
我有一个游戏对象,它围绕 z 轴倾斜 x 度,围绕 x 轴倾斜 z 度。我设法使用以下代码做到了这一点
public float xtilt, ztilt, ytilt;
//These virables are public float values for how much tilt or rotation I want.
//xtilt for how much rotation when moving on the x axis.
//ztilt for how much rotation when moving on the z axis.
//ytilt for how much rotation when moving on the y axis.
void FixedUpdate()
{
Rigidbody rb;
rb.rotation = Quaternion.Euler(rb.velocity.z * ztilt, 0.0f, rb.velocity.x * -xtilt);
}
上面的代码给了我关注
- 当围绕 z 轴移动时,游戏对象旋转 x 度。
- 当围绕 x 轴移动时,游戏对象旋转 z 度。
目标:
我要添加:围绕 y 轴旋转或倾斜游戏对象 x 度。
所以它会是这样的:
- 当围绕 y 轴移动时,游戏对象旋转 x 度。
我试图绕过代码来实现这一点,但没有成功。
有什么想法吗??
【问题讨论】: