一个很简单的功能,网上给的都非常复杂,实际上几行代码就搞定了
if(Input.GetMouseButton(0))
{
mouse_x += Input.GetAxis("Mouse X") * rotSpeed * Time.deltaTime;
mouse_y += Input.GetAxis("Mouse Y") * rotSpeed * Time.deltaTime;
q = Quaternion.Euler(-mouse_y, mouse_x, 0);
Vector3 axis = new Vector3(0, 0, -zAxis);
Vector3 pos = q * axis + player.transform.position + offset;
transform.localPosition = pos;
transform.LookAt(player);
}
就这样