我需要围绕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);