如何像人头一样限制相机旋转

时间:2018-05-31 15:30:49

标签: unity3d

控制器凸轮和播放器的rb

public void controladortrajeCamLibre(){///camara libre
    Vector2 md = new Vector2 (Input.GetAxisRaw ("Mouse X"), Input.GetAxisRaw ("Mouse Y"));  md = Vector2.Scale (md, new Vector2 (sensitivity * smothing, sensitivity * smothing));
    smoothV.x = Mathf.Lerp (smoothV.x, md.x, 1.0f / smothing);
    smoothV.y = Mathf.Lerp (smoothV.y, md.y, 1.0f / smothing);
    mouseLook += smoothV;
    cam.transform.localRotation = Quaternion.AngleAxis (-mouseLook.y, Vector3.right);
    character.transform.localRotation = Quaternion.AngleAxis (mouseLook.x, character.transform.up);
    }

1 个答案:

答案 0 :(得分:0)

您可以使用Mathf.Clamp来限制相机的旋转。