How do I make my character charge!

0 favourites
  • 3 posts
From the Asset Store
2d warrior machrom platformer game character assets
  • Hi Folks,

    Here's my request

    When I press Z my character hit

    When I press Z and hold for at least 1 second, my character charges and hit differently.

    I tried with keyboard presses but didn't work.. maybe I need to create variables and compare time vs 1 second and presses...etc. not sure

    Your help will be greatly appreciated

    Thx 😊

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Use the timer behavior. You can use multiple timers with tags.

    For the quick hit, on key pressed set a timer "attack" for 0.1s, and another timer "charge" for 1s.

    On key released, stop the charge timer.

    On timer "attack" trigger, check to see if timer "charge" is running. If it isn't, then attack.

    On timer "charge" triggered, then you can immediately unleash the charged attack, or set a variable "charged" to true. On key released, if "charged" is true, then do charged attack.

    Note that games like Zelda classically do the normal attack first no matter if you hold the button down or not, that would make it simpler. Then you simply check if the key is still down up on the animation finished to start the charge timer.

  • Here a shooting charge example to help you understand the mechanics:

    dropbox.com/s/helqwnbyctohaoi/charge_hold.capx

    Hopefully the logic can be applied to your project.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)