コード例 #1
0
    void FixedUpdate()
    {
        InputDevice  player      = InputManager.ActiveDevice;
        InputControl movecontrol = player.GetControl(InputControlType.LeftStickX);

        Move(movecontrol.Value);

        myAnim.SetFloat("moveSpeed", Mathf.Abs(movecontrol.Value));

        if (movecontrol.Value > .01f)
        {
            transform.localScale = new Vector2(1, transform.localScale.y);
        }

        if (movecontrol.Value < -.01f)
        {
            transform.localScale = new Vector2(-1, transform.localScale.y);
        }

        //Now checks if the trigger is active
        if (player.Action2 && myTrigger.GetIsActive())
        {
            Jump();
            myTrigger.BeatHit();
        }

        //Dash Ability
        if (player.Action3 && myTrigger.GetIsActive())
        {
            //negative on the y to invert stick for some reason
            Dash(Input.GetAxisRaw("L_XAxis_1"), -Input.GetAxisRaw("L_YAxis_1"));
            myTrigger.BeatHit();
        }

        //Alt jump for testing
        if (Input.GetKeyDown(KeyCode.D) && myTrigger.GetIsActive())
        {
            Jump();
            myTrigger.BeatHit();
        }

        //Alt dash for testing
        if (Input.GetKeyDown(KeyCode.S) && myTrigger.GetIsActive())
        {
            Dash(1, 1);
            myTrigger.BeatHit();
        }

        // player is falling
        if (mybody.velocity.y < 0)
        {
            mybody.velocity += Vector2.up * Physics2D.gravity.y * (fallMultiplier - 1) * Time.deltaTime;
            // minus 1 because unity is already applying 1 multiple of the gravity (don't want to add gravity part twice)
        }
        // player is moving up in the jump and a is released
        else if (mybody.velocity.y > 0) //&& !Input.GetButton("A_1"))
        {
            mybody.velocity += Vector2.up * Physics2D.gravity.y * (lowJumpMultiplier - 1) * Time.deltaTime;
        }
    }
コード例 #2
0
    void FixedUpdate()
    {
        Move(Input.GetAxisRaw("L_XAxis_2"));

        //Now checks if the trigger is active
        if (Input.GetButtonDown("Y_2") && myTrigger.GetIsActive())
        {
            Jump();
            myTrigger.BeatHit();
        }

        //Dash Ability
        if (Input.GetButtonDown("B_2") && myTrigger.GetIsActive())
        {
            //negative on the y to invert stick for some reason
            Dash(Input.GetAxisRaw("L_XAxis_2"), -Input.GetAxisRaw("L_YAxis_1"));
            myTrigger.BeatHit();
        }

        //Alt jump for testing
        if (Input.GetKeyDown(KeyCode.D) && myTrigger.GetIsActive())
        {
            Jump();
            myTrigger.BeatHit();
        }

        //Alt dash for testing
        if (Input.GetKeyDown(KeyCode.S) && myTrigger.GetIsActive())
        {
            Dash(1, 1);
            myTrigger.BeatHit();
        }

        // player is falling
        if (mybody.velocity.y < 0)
        {
            mybody.velocity += Vector2.up * Physics2D.gravity.y * (fallMultiplier - 1) * Time.deltaTime;
            // minus 1 because unity is already applying 1 multiple of the gravity (don't want to add gravity part twice)
        }
        // player is moving up in the jump and a is released
        else if (mybody.velocity.y > 0) //&& !Input.GetButton("A_1"))
        {
            mybody.velocity += Vector2.up * Physics2D.gravity.y * (lowJumpMultiplier - 1) * Time.deltaTime;
        }
    }