Beispiel #1
0
    // If you are ever wondering why you are having issues with dropped button presses, it's because it's not in here!
    private void Update()
    {
        if (!hasAuthority)
        {
            return;
        }

        // Other actions
        if (Input.GetButtonDown("Left Click"))
        {
            action.GrabAction();
        }

        // Check to see if we should do single action or perform continuous action
        if (action.continuousAction)
        {
            if (Input.GetButton("Right Click"))
            {
                action.UseAction();
            }
        }
        else
        {
            if (Input.GetButtonDown("Right Click"))
            {
                action.UseAction();
            }
        }
    }
Beispiel #2
0
    // Update is called once per frame
    private void Update()
    {
        if (!hasAuthority)
        {
            return;
        }

        if (!action.controlEnabled)
        {
            return;
        }

        // Store the input axes.
        h = Input.GetAxis(joyPrefix + "JoyH");
        v = Input.GetAxis(joyPrefix + "JoyV");


        // Our own deadzone implementation
        stickInput = new Vector2(h, v);
        if (stickInput.magnitude < deadzone)
        {
            stickInput = Vector2.zero;
        }
        else
        {
            stickInput = stickInput.normalized * ((stickInput.magnitude - deadzone) / (1 - deadzone));
        }

        // Only send the new output if the stick input is past the deadzone
        if (stickInput.x != 0 || stickInput.y != 0)
        {
            SmoothLook(new Vector3(stickInput.x, 0, stickInput.y));
        }

        //In the joypad controller, we add the joyPrefix (Which is a string set externally by the local player manager)
        // Button commands
        if (Input.GetButtonDown(joyPrefix + "Pick"))
        {
            action.GrabAction();
        }


        // Check to see if we should do single action or perform continuous action
        if (action.continuousAction)
        {
            if (Input.GetButton(joyPrefix + "Use"))
            {
                action.UseAction();
            }
        }
        else
        {
            if (Input.GetButtonDown(joyPrefix + "Use"))
            {
                action.UseAction();
            }
        }
    }