Exemplo n.º 1
0
        /// <summary>
        /// Processes the inputs. This MUST ONLY BE USED when the player has authority over this Networked GameObject (photonView.isMine == true)
        /// </summary>
        void ProcessInputs()
        {
            //INPUT CONTROLS HERE
            if (Input.GetKeyUp(KeyCode.W) || Input.GetKeyUp(KeyCode.A) || Input.GetKeyUp(KeyCode.S) || Input.GetKeyUp(KeyCode.D))
            {
                LocalPlayerScript.physicsMove.MoveInputReleased();
            }

            Vector2 direction = Vector2.zero;

            //hold key down inputs. clampPos is used to snap player to an axis on movement

            if (Input.GetKey(KeyCode.D))
            {
                //RIGHT
                direction = Vector2.right;
            }
            if (Input.GetKey(KeyCode.A))
            {
                //LEFT
                direction = Vector2.left;
            }
            if (Input.GetKey(KeyCode.S))
            {
                //DOWN
                direction = Vector2.down;
            }
            if (Input.GetKey(KeyCode.W))
            {
                //UP
                direction = Vector2.up;
            }

            if (direction != Vector2.zero)
            {
                LocalPlayerScript.MovePlayer(direction);
            }
        }