// Update is called once per frame
        void Update()
        {
            // If player presses escape, lock cursor inside the screen however making it visible
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                Cursor.lockState = CursorLockMode.Confined;
            }
            // If player presses w, lock cursor
            if (Input.GetKeyDown(KeyCode.W))
            {
                Cursor.lockState = CursorLockMode.Locked;
            }

            // Allow the player to move and jump
            player.MouseRotateHorizontal();
            player.MouseRotateVertical();

            float v = Input.GetAxis("Vertical");
            float h = Input.GetAxis("Horizontal");

            player.Move(h, v);

            if (Input.GetButtonDown("Jump"))
            {
                player.Jump();
            }
        }
Exemple #2
0
        void Update()
        {
            // If it is the local player
            if (isLocalPlayer)
            {
                // IF player presses escape, unlock cursor
                if (Input.GetKeyDown(KeyCode.Escape))
                {
                    Cursor.lockState = CursorLockMode.Confined;
                }
                // IF player presses w, lock cursor
                if (Input.GetKeyDown(KeyCode.W))
                {
                    Cursor.lockState = CursorLockMode.Locked;
                }

                // Allow the player to move and jump
                player.MouseRotateHorizontal();
                player.MouseRotateVertical();

                float v = Input.GetAxis("Vertical");
                float h = Input.GetAxis("Horizontal");
                player.Move(h, v);

                if (Input.GetButtonDown("Jump"))
                {
                    player.Jump();
                }
            }
        }