Unity3d只在z轴上旋转

时间:2014-10-06 14:20:52

标签: unity3d rotation quaternions

我需要围绕Z轴旋转的GameObject。它需要一直面对光标。但它在所有轴上旋转。这是代码:

Vector3 mouseClickPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Vector3 dir = mouseClickPos - transform.position;
Vector3 h1dir = Vector3.RotateTowards(hand1.transform.forward, dir, 6.0f, 1.0f);
hand1.transform.rotation = Quaternion.LookRotation(h1dir);

0 个答案:

没有答案