示例#1
0
    public override void UserInput()
    {
        //if (m_ShootMode)
        //{
        //    if (m_SyncYaw && m_Character != null && !CamInput.GetKey(m_RotateKey))
        //    {
        //        m_YawWanted = Mathf.Atan2(m_Character.transform.forward.x, m_Character.transform.forward.z) * Mathf.Rad2Deg;
        //        int trunc = Mathf.RoundToInt((m_Yaw - m_YawWanted) / 360.0f);
        //        m_Yaw -= trunc * 360.0f;
        //        m_Yaw = Mathf.Lerp(m_Yaw, m_YawWanted, Mathf.Clamp01(Time.deltaTime * m_YawDamper));
        //    }
        //    base.UserInput();
        //    //if (m_EnableFov && !m_Controller.m_MouseOnScroll)
        //    //{
        //    //    float delta_fov = m_FovSensitivity * CamInput.GetAxis(m_FovAxis) * 10;
        //    //    m_FovWanted += delta_fov;
        //    //    m_FovWanted = Mathf.Clamp(m_FovWanted, Mathf.Max(-30, m_MinFov), Mathf.Min(90, m_MaxFov));
        //    //    m_Fov = Mathf.Lerp(m_Fov, m_FovWanted, Mathf.Clamp01(Time.deltaTime * m_FovDamper));
        //    //}
        //}
        //else
        //{
        if (m_SyncYaw && m_Character != null && !CamInput.GetKey(m_RotateKey))
        {
            m_YawWanted = Mathf.Atan2(m_Character.transform.forward.x, m_Character.transform.forward.z) * Mathf.Rad2Deg;
            int trunc = Mathf.RoundToInt((m_Yaw - m_YawWanted) / 360.0f);
            m_Yaw -= trunc * 360.0f;
            m_Yaw  = Mathf.Lerp(m_Yaw, m_YawWanted, Mathf.Clamp01(Time.deltaTime * m_YawDamper));
        }
        if (m_SyncPitch && m_Character != null && !CamInput.GetKey(m_RotateKey))
        {
            m_PitchWanted = -Mathf.Asin(Mathf.Clamp(m_Character.transform.forward.y, -1, 1)) * Mathf.Rad2Deg;
            m_PitchWanted = Mathf.Clamp(m_PitchWanted, m_MinPitch, m_MaxPitch);
            m_Pitch       = Mathf.Lerp(m_Pitch, m_PitchWanted, Mathf.Clamp01(Time.deltaTime * m_PitchDamper));
        }
        base.UserInput();
        if (m_EnableZoom && !m_Controller.m_MouseOnScroll)
        {
            float delta_z = Mathf.Pow(m_ZoomSensitivity + 1F, CamInput.GetAxis(m_ZoomAxis));
            m_DistanceWanted *= delta_z;
            m_DistanceWanted  = Mathf.Clamp(m_DistanceWanted, Mathf.Max(0.001f, m_MinDistance), m_MaxDistance);
            m_Distance        = Mathf.Lerp(m_Distance, m_DistanceWanted, Mathf.Clamp01(Time.deltaTime * m_DistDamper));

            //if (m_ShootReady)
            //{
            //    if (m_Distance < 1.41f && m_Distance > 1.39f)
            //    {
            //        m_ShootMode = true;
            //        m_ShootReady = false;
            //    }
            //}
        }
        //}
    }
示例#2
0
    public override void UserInput()
    {
        bool rot = m_EnableRotate && (m_LockCursor || CamInput.GetKey(m_RotateKey) && !m_Controller.m_MouseOpOnGUI);

        Cursor.lockState = m_LockCursor ? CursorLockMode.Locked : Screen.fullScreen? CursorLockMode.Confined: CursorLockMode.None;
        Cursor.visible   = !m_LockCursor;

        if (rot)
        {
            float delta_x = (CamInput.GetAxis(ECamKey.CK_MouseX) + CamInput.GetAxis(ECamKey.CK_JoyStickX)) * m_RotateSensitivity;
            float delta_y = (CamInput.GetAxis(ECamKey.CK_MouseY) + CamInput.GetAxis(ECamKey.CK_JoyStickY)) * m_RotateSensitivity;
            m_Yaw   += delta_x;
            m_Pitch += delta_y;
        }
        m_Pitch = Mathf.Clamp(m_Pitch, m_MinPitch, m_MaxPitch);
    }
示例#3
0
 public override void UserInput()
 {
     base.UserInput();
     if (m_Character != null)
     {
         Vector3 forward = m_Character.transform.forward;
         if (m_AutoFollow)
         {
             if (!CamInput.GetKey(m_RotateKey))
             {
                 if (_lastCharacterPos.sqrMagnitude > 0.01f)
                 {
                     float ofs = (m_Character.position - _lastCharacterPos).magnitude;
                     if (ofs > 0.03f)
                     {
                         if (_moving_time > m_AutoFollowDelay)
                         {
                             m_YawWanted = Mathf.Atan2(forward.x, forward.z) * Mathf.Rad2Deg;
                             int trunc = Mathf.RoundToInt((m_Yaw - m_YawWanted) / 360.0f);
                             m_Yaw -= trunc * 360.0f;
                             m_Yaw  = Mathf.Lerp(m_Yaw, m_YawWanted, Mathf.Clamp01(0.03f * m_YawDamper));
                         }
                         _moving_time += Time.deltaTime;
                     }
                     else
                     {
                         if (_moving_time > m_AutoFollowDelay)
                         {
                             _moving_time = m_AutoFollowDelay;
                         }
                         _moving_time -= Time.deltaTime;
                         if (_moving_time < 0)
                         {
                             _moving_time = 0;
                         }
                     }
                 }
                 else
                 {
                     _moving_time = 0;
                 }
             }
         }
         _lastCharacterPos = m_Character.position;
     }
 }
示例#4
0
 public override void UserInput()
 {
     if (m_SyncYaw && m_Character != null && !CamInput.GetKey(m_RotateKey))
     {
         m_YawWanted = Mathf.Atan2(m_Character.transform.forward.x, m_Character.transform.forward.z) * Mathf.Rad2Deg;
         int trunc = Mathf.RoundToInt((m_Yaw - m_YawWanted) / 360.0f);
         m_Yaw -= trunc * 360.0f;
         m_Yaw  = Mathf.Lerp(m_Yaw, m_YawWanted, Mathf.Clamp01(Time.deltaTime * m_YawDamper));
     }
     base.UserInput();
     if (m_EnableFov && !m_Controller.m_MouseOnScroll)
     {
         float delta_fov = m_FovSensitivity * CamInput.GetAxis(m_FovAxis) * 10;
         m_FovWanted += delta_fov;
         m_FovWanted  = Mathf.Clamp(m_FovWanted, Mathf.Max(-30, m_MinFov), Mathf.Min(90, m_MaxFov));
         m_Fov        = Mathf.Lerp(m_Fov, m_FovWanted, Mathf.Clamp01(Time.deltaTime * m_FovDamper));
     }
 }
示例#5
0
    public override void UserInput()
    {
        base.UserInput();
        Vector3 move = Vector3.zero;

        if (CamInput.GetKey(m_MoveLeftKey))
        {
            move -= m_TargetCam.transform.right;
        }
        if (CamInput.GetKey(m_MoveRightKey))
        {
            move += m_TargetCam.transform.right;
        }
        if (CamInput.GetKey(m_MoveForwardKey))
        {
            move += m_TargetCam.transform.forward;
        }
        if (CamInput.GetKey(m_MoveBackKey))
        {
            move -= m_TargetCam.transform.forward;
        }
        if (CamInput.GetKey(m_MoveUpKey))
        {
            move += m_TargetCam.transform.up;
        }
        if (CamInput.GetKey(m_MoveDownKey))
        {
            move -= m_TargetCam.transform.up;
        }

        m_MoveDir = move;

        if (move.sqrMagnitude > 0)
        {
            m_CurrSpeed += (m_MoveAcceleration * Time.deltaTime);
        }
        else
        {
            m_CurrSpeed = m_MoveSpeed;
        }
    }
示例#6
0
    private void Update()
    {
        rb.velocity = Vector3.ClampMagnitude(rb.velocity, velocityClamp);

        if (Input.GetMouseButton(0))
        {
            if (Time.frameCount % 5 == 0)
            {
                jumpDirection = thisTransform.position - CamInput.MousePosition(Input.mousePosition);
            }
        }

        if (Input.GetMouseButtonUp(0) && !inJump)
        {
            force = Vector3.ClampMagnitude(jumpDirection.normalized * jumpDirection.magnitude * jumpMultiplayer, velocityClamp);
            rb.AddForce(force, ForceMode.Impulse);
            inJump = true;
        }
        if (thisTransform.position.y < 0)
        {
            SceneManager.LoadScene(0);
        }
    }