コード例 #1
0
        // Fixed update is called in sync with physics
        void FixedUpdate()
        {
            // read inputs
            float h = Input.GetAxis("Horizontal");
            float v = -Input.GetAxis("Vertical");

            // calculate move direction to pass to character
            if (m_Cam != null)
            {
                // calculate camera relative direction to move:
                m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized;
                m_Move       = v * m_CamForward + h * m_Cam.right;
            }
            else
            {
                // we use world-relative directions in the case of no main camera
                m_Move = v * Vector3.forward + h * Vector3.right;
            }
#if !MOBILE_INPUT
            // walk speed multiplier
            if (Input.GetKey(KeyCode.LeftControl) && !sprint && !crouch)
            {
                m_Move *= 0.6f;
            }
#endif
            if (sprint && m_Move.magnitude < 0.2f)
            {
                sprint = false;
            }

            // pass all parameters to the character control script
            if (cover)
            {
                m_Character.Move(m_Move, true, m_Jump, sprint);
            }
            else
            {
                m_Character.Move(m_Move, crouch, m_Jump, sprint);
            }
            m_Jump = false;
        }
コード例 #2
0
    void FixedUpdate()
    {
        if (!ragdolling)
        {
            float h = Input.GetAxis(horizontalMovement);
            float v = -Input.GetAxis(verticalMovement);

            // calculate move direction to pass to character
            if (m_Cam != null)
            {
                // calculate camera relative direction to move:
                m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized;
                m_Move       = v * m_CamForward + h * m_Cam.right;
            }
            else
            {
                // we use world-relative directions in the case of no main camera
                m_Move = v * Vector3.forward + h * Vector3.right;
            }
            // walk speed multiplier
            if (Input.GetButton(Walk) && !sprint)
            {
                m_Move *= 0.6f;
            }
            if (sprint && m_Move.magnitude < 0.2f)
            {
                sprint = false;
            }

            // pass all parameters to the character control script
            if (cover)
            {
                tpMotor.Move(m_Move, true, m_Jump, sprint);
            }
            else
            {
                tpMotor.Move(m_Move, crouch, m_Jump, sprint);
            }
            m_Jump = false;
        }
    }
コード例 #3
0
 public void DisableRagdoll()
 {
     tpMotor.Move(Vector3.zero, false, false);
     tpInput.ragdolling  = false;
     tpAimScript.enabled = true;
     ragdolling          = false;
     anim.enabled        = true;
     //mainRB.constraints = RigidbodyConstraints.FreezeRotation;
     mainRB.isKinematic = false;
     mainCol.enabled    = true;
     root.transform.SetParent(transform);
 }