Double Tap Buttons to Toggle Actions (Gamepad)

2

Stats

979 visits, 1,162 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 26 Sep, 2019.

Hello Everyone,

This is my first post for the construct community! I've read several older articles regarding the creation of toggled actions for a single button. I've decided to create this tutorial as a solution to those questions.

This post is specific to the Xbox One Controller for Windows but it can be translated for other input devices with relative ease.

In this tutorial we will make our character sprint by tapping left analog button and we will stop his sprint by tapping left analog button again. And away we go!

You will need two Boolean Instance Variables for your character, I've named them:

IsSprinting

and

IsSprintToggled

Initial State for both Variables is FALSE

Here are the Sprint Events and Actions:

Gamepad:On Left Analog Button Pressed -> Character: Set IsSprinting TRUE

Character: XIsSprinting (Inversion)

Character: IsSprinting -> Character: Set 8 Direction Max Speed to 100

Gamepad:On Left Analog Button Released -> Character: Set IsSprintToggled TRUE

Character: IsSprinting

Gamepad:On Left Analog Button Pressed -> Character: Set IsSprinting FALSE

Character: IsSprintToggled

Character: XIsSprinting (Inversion) -> Character: Set 8 Direction Max Speed to 50

Character: Set IsSprintToggled FALSE

Gamepad: Left Analog Stick Y = 0 -> Character: Set IsSprinting FALSE

Gamepad: Left Analog Stick X = 0

TheEnd

You should now be able to tap the left analog button to increase speed, press again to "resume" your original speed before sprinting (assuming it's 50 pixels/second)

and release the analog stick to also stop the sprint action.

This way, you can stop sprinting while still moving AND you can also stop sprinting by simply stopping the character.

I really hope this helps the community! (Hopefully, I didn't reinvent the wheel)

  • 0 Comments

Want to leave a comment? Login or Register an account!