示例#1
0
    void mouseOrbitSet()
    {
        // x += Input.GetAxis("Mouse X") * xSpeed;
        // y -= Input.GetAxis("Mouse Y") * ySpeed;

        if (orbitCamera)
        {
            x = MathS.easeInOutExpo(Time.time - orbitCameratime, startX, finalX, 0.25f);
        }
        y = ClampAngle(y, yMinLimit, yMaxLimit);

        if (Time.time - orbitCameratime >= 0.5)
        {
            orbitCamera = false;
        }

        Quaternion rotation = Quaternion.Euler(y, x, 0);

        distance = Mathf.Clamp(distance - Input.GetAxis("Mouse ScrollWheel") * 5, distanceMin, distanceMax);


        Vector3 position = rotation * new Vector3(0.0f, 0.0f, -distance) + maingameCS.getPlayerPos() + targetMove;

        transform.rotation = rotation;
        transform.position = position;

        //更新攝影機與目標的相對位置
        maingameCS.cameraRELtarget = maingameCS.mainCamera.transform.position - maingameCS.getPlayerPos();
    }