Ejemplo n.º 1
0
    private Vector2 GetInput()
    {
        Vector2 input = new Vector2
        {
            x = CrossPlatformInputManager.GetAxis("Horizontal"),
            y = CrossPlatformInputManager.GetAxis("Vertical")
        };

        movementSettings.UpdateDesiredTargetSpeed(input);
        return(input);
    }
Ejemplo n.º 2
0
    private Vector2 GetInput(float horizontal, float vertical, bool run)
    {
        Vector2 input = new Vector2
        {
            x = horizontal,
            y = vertical
        };

        movementSettings.UpdateDesiredTargetSpeed(input, run);
        return(input);
    }
Ejemplo n.º 3
0
        private Vector2 GetInput()
        {
            if (Input.GetKey(KeyCode.W))
            {
                verticalInputValue = 1f;
            }
            else if (Input.GetKey(KeyCode.S))
            {
                verticalInputValue = -1f;
            }
            else
            {
                verticalInputValue = 0f;
            }

            if (Input.GetKey(KeyCode.A))
            {
                horizontalInputValue = -1f;
            }
            else if (Input.GetKey((KeyCode.D)))
            {
                horizontalInputValue = 1f;
            }
            else
            {
                horizontalInputValue = 0f;
            }

            Vector2 input = new Vector2
            {
                x = horizontalInputValue,
                y = verticalInputValue
            };


            //UNCOMMENT FOR REGULAR CROSS-PLATFORM INPUT

            /*Vector2 input = new Vector2
             *  {
             *      x = CrossPlatformInputManager.GetAxis("Horizontal"),
             *      y = CrossPlatformInputManager.GetAxis("Vertical")
             *  };*/
            Debug.Log(input);

            movementSettings.UpdateDesiredTargetSpeed(input);
            return(input);
        }
Ejemplo n.º 4
0
    private Vector2 GetInput()
    {
        Vector2 input = new Vector2
        {
            x = CrossPlatformInputManager.GetAxis("Horizontal"),
            y = CrossPlatformInputManager.GetAxis("Vertical")
        };

        if (input == Vector2.zero)
        {
            m_Braking = true;
        }
        else
        {
            m_Braking = false;
            movementSettings.UpdateDesiredTargetSpeed(input);
        }

        return(input);
    }
Ejemplo n.º 5
0
    private Vector2 GetInput()
    {
        if (voiceRecorder != null)
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                voiceRecorder.Transmit = !voiceRecorder.Transmit;
                owner.Mute(!voiceRecorder.Transmit);
            }
        }

        Vector2 input = new Vector2
        {
            x = CrossPlatformInputManager.GetAxis("Horizontal"),
            y = CrossPlatformInputManager.GetAxis("Vertical")
        };

        movementSettings.UpdateDesiredTargetSpeed(input);
        return(input);
    }
Ejemplo n.º 6
0
    private Vector2 GetInput()
    {
        Vector2 input = new Vector2
        {
            x = Input.GetAxis("Horizontal"),
            y = Input.GetAxis("Vertical")
        };

        movementSettings.UpdateDesiredTargetSpeed(input);

        bool wasWalking = !Running;

        Running = Input.GetKey(KeyCode.LeftShift); //Keep track of whether or not the character is walking or running.

        if (!Running != wasWalking && useFovKick && rigidBody.velocity.sqrMagnitude > 0f)
        {
            StopAllCoroutines();
            StartCoroutine(Running ? fovKick.FOVKickUp() : fovKick.FOVKickDown());
        }

        return(input);
    }
Ejemplo n.º 7
0
        private Vector2 GetInput()
        {
            movementSettings.UpdateDesiredTargetSpeed();
            Vector2 input = new Vector2(0, 0);

            if (Cardboard.SDK.Triggered)
            {
                isMoving = !isMoving;
            }

            if (isMoving)
            {
                input = new Vector2(0, 2);
            }

            /*Vector2 input = new Vector2
             *  {
             *      x = CrossPlatformInputManager.GetAxis("Horizontal"),
             *      y = CrossPlatformInputManager.GetAxis("Vertical")
             *  };
             */
            Debug.Log("GetInput() - input:" + input + "   - isMoving:" + isMoving);
            return(input);
        }
    private void FixedUpdate()
    {
        if (!isLocalPlayer)
        {
            return;
        }

        Vector2 input = GetInput();

        movementSettings.UpdateDesiredTargetSpeed(input);

        if ((Mathf.Abs(input.x) > float.Epsilon || Mathf.Abs(input.y) > float.Epsilon))
        {
            if (((m_IsGrounded || m_IsRoofed) || airControl.Useable) && !airControl.Disabled)
            {
                if (!m_IsGrounded && !m_IsRoofed)
                {
                    airControl.Use(); //Utilisation du air control
                }
                // always move along the camera forward as it is the direction that it being aimed at
                Vector3 desiredMove = cam.transform.forward * input.y + cam.transform.right * input.x;
                desiredMove = Vector3.ProjectOnPlane(desiredMove, m_GroundContactNormal).normalized;

                desiredMove.x = desiredMove.x * movementSettings.CurrentTargetSpeed;
                desiredMove.y = desiredMove.y * movementSettings.CurrentTargetSpeed;
                desiredMove.z = desiredMove.z * movementSettings.CurrentTargetSpeed;
                if (m_RigidBody.velocity.sqrMagnitude <
                    (movementSettings.CurrentTargetSpeed * movementSettings.CurrentTargetSpeed))
                {
                    GetComponent <SoundPlayerManager>().StartDeplacement();
                    //Debug.Log("Start");
                    m_RigidBody.AddForce(desiredMove, ForceMode.Impulse);
                }
            }
        }
        else
        {
            GetComponent <SoundPlayerManager>().StopDeplacement();
            //Debug.Log("Stop");
        }

        if (m_IsGrounded || m_IsRoofed)
        {
            airControl.Reload(); //Rechargement du air control
        }

        if ((m_IsGrounded || m_IsRoofed || m_Jumpable) && m_Jump)
        {
            m_RigidBody.velocity = new Vector3(m_RigidBody.velocity.x, 0f, m_RigidBody.velocity.z);

            if (m_IsGrounded || (m_Jumpable && playerWeight.CurrentWeight >= 0))
            {
                m_RigidBody.AddForce(new Vector3(0f, movementSettings.JumpForce, 0f), ForceMode.Impulse);
            }
            else if (m_IsRoofed || (m_Jumpable && playerWeight.CurrentWeight <= 0))
            {
                m_RigidBody.AddForce(new Vector3(0f, -movementSettings.JumpForce, 0f), ForceMode.Impulse);
            }
            m_Jumping = true;
        }
        m_Jump = false;
        ApplyDeceleration(); //Application de la resistance au sol et a l'air
    }