Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(1) && playerIsDead == false)
        {
            followCam.MouseLookOn(m_Damping, m_LookAheadFactor, m_LookAheadReturnSpeed, m_LookAheadMoveThreshold);
        }
        if (Input.GetMouseButton(1) && playerIsDead == false)
        {
            Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            if (Vector3.Distance(Camera.main.transform.position, mousePos) > aimTolerance)
            {
                Vector3 newPos = Vector3.zero;
                int     deltaX = (int)(mousePos.x - center.position.x);
                newPos.x = deltaX;
                int deltaY = (int)(mousePos.y - center.position.y);
                newPos.y = deltaY;

                transform.position = Vector3.ClampMagnitude(new Vector3(newPos.x, newPos.y, newPos.z), distance) + center.position;
            }
        }
        else if (Input.GetMouseButtonUp(1) && playerIsDead == false)
        {
            followCam.MouseLookOff();
            if (transform.parent != null)
            {
                transform.localPosition = Vector3.zero;
            }
        }
    }