Пример #1
0
    // Fixed update is called in sync with physics
    private void FixedUpdate()
    {
        // read inputs
        float h      = CrossPlatformInputManager.GetAxis("Horizontal");
        float v      = CrossPlatformInputManager.GetAxis("Vertical");
        bool  crouch = Input.GetKey(KeyCode.C);

        // 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.LeftShift))
        {
            m_Move *= .5f;
        }
#endif

        // pass all parameters to the character control script
        m_Character.Move(m_Move, crouch, m_Jump, m_Glide, m_Surf);
        m_Jump  = false;
        m_Glide = false;
        m_Surf  = false;
    }
Пример #2
0
    private void FixedUpdate()
    {
        if (!photonView.isMine)
        {
            return;
        }
        //Ou on va
        float h = CrossPlatformInputManager.GetAxis("Horizontal");
        float v = CrossPlatformInputManager.GetAxis("Vertical");

        //Calculer dans quelle direction il va falloir aller
        if (m_Cam != null)
        {
            //Calculer comment la caméra va aussi devoir bouger
            m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized;
            m_Move       = v * m_CamForward + h * m_Cam.right;
        }
        else
        {
            //Sinon, on se déplace tout droit
            m_Move = v * Vector3.forward + h * Vector3.right;
        }
        if (Input.GetKey(KeyCode.LeftShift))
        {
            m_Move *= 0.5f;
        }
        // Envoyer les mouvements a thirdpersoncharacter
        m_Character.Move(m_Move, false, m_Jump);
        m_Jump = false;
    }