Knockback in Platformer

0 favourites
  • 4 posts
From the Asset Store
10 Retro songs ideal for platformers or farming games
  • So I'm trying to make a system in which when a player or enemy with platform behavior gets hit with a certain attack, they are knocked back and briefly stunned. This kind of mechanic is common in a lot of games, such as fighting games. I have the basics in place - stunning the player and disabling their controls, but getting the actual knockback to work continues to give me trouble.

    Knockup in a vertical direction is fairly easy, you just set the Vector Y on the platform behavior and it behaves appropriately. Moving the player in the horizontal direction is more difficult, because the Vector X is affected by the platform behavior's natural deceleration, which is pretty high in my game. I don't want to lower the ground deceleration too much or I'll lose the precise feeling of the controls, but as it is even if I set the vector X to the max speed the platform behavior allows it still barely moves the character backwards at all.

    Is there an alternate method to handle knockback better, one that would give me more control? I'd like to be able to do large knockbacks (ie: hit a character across a screen's length), ideally with some control over things like deceleration. It's also important that the knockback continue to interact correctly with solids, such that the character can't be thrown through walls and won't end up with their platform behavior bugged out.

    Any thoughts? Have others had to approach this problem? What kind of solutions did you use?

  • Hi,

    you can set the max speed and deceleration temporarily,

    and then set it back to the previous value after the player regain control

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you think of it like the difference between force and impulse in the physics behaviour, instead of applying a vector adjustment once, which would straight away be affected by deceleration, instead, set a variable, and while true , set vector.x to a certain amount.

    I did this for wall jumps in a game, I set a variable to 80, then each tick, subtracted 1 from variable, and set vector-x to a fixed number, so the character would move in the air/repel from walls.

    Once it hit 0, the vector.x wasn't affected any more.

  • If you think of it like the difference between force and impulse in the physics behaviour, instead of applying a vector adjustment once, which would straight away be affected by deceleration, instead, set a variable, and while true , set vector.x to a certain amount.

    I did this for wall jumps in a game, I set a variable to 80, then each tick, subtracted 1 from variable, and set vector-x to a fixed number, so the character would move in the air/repel from walls.

    Once it hit 0, the vector.x wasn't affected any more.

    That approach makes a lot of sense, I'll give it a try. Thanks!

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