Knockback

0 favourites
  • 7 posts
  • Basically I want to make my character knock back when hit by an enemy so that you can't be hit in rapid succession. Something similar to this in Monster World 4:

    youtu.be/BhKZXacyPTY

    I though I might be able to do it by simulating the platformer jump action but that only makes him jump straight up and also too high. For some reason when using simulate jump I can't change the jump strength or direction. Any Ideas?

    Here is a link to my .capx, the blue square is the enemy. Arrows to move, space to jump:

    mediafire.com

  • Sorry to bump this but it's something that is really stumping me.

  • I'm having the same problem, and no one will answer me either. The best ive done is given the object physics behavior, and on collision, turn physics behavior on, and set force towards something (some value of x and y)   but this doesnt work very well for me because i can only get the character to knockback in one direction so far. I want it to knockback depending on where the player was hit

  • bscarl88

    When the knock back happens check the players X position against the enemies X position. If players X is less than enemies X do the knock back from the bottom right of player. If the enemies X is less than players X then do the knock back from bottom left of player.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • bscarl88

    When the knock back happens check the players X position against the enemies X position. If players X is less than enemies X do the knock back from the bottom right of player. If the enemies X is less than players X then do the knock back from bottom left of player.

    hmmm great idea! I was wondering how I could do this with a 4 player fighting game.   I guess I would have to check all combinations of P1 vs P2, P2 vs P3, P1 vs P3 etc

  • You have to use "set platform vector".

    I did something like this on my GGJ project earlier this year. It works, but if you want the player to be knocked back depending on the side on which he has been hit, you've got to add some things. This is also kind of a mess because I did it in a hurry.

    Here's that bit of code:

    <img src="http://i.imgur.com/ljrN3.png" border="0" />

    Basically what's it saying is:

    ---

    IF the player has been hit

    AND he isn't invicible/blinking

    AND the ducking animation isn't playing (he uses a shield when he's ducked)

    Then

    Deactivate the controls group

    Set animation to hit

    Set invicible var to 1 (which makes him blink and be invicible for a short period of time)

    Set platform vector Y to -200 (this makes the player move up, if you want to increase/decrese the size just mess with the number, but it has to be negative for him to go up)

    Subtract one from health

    ---

    If you want to have him be knocked back instead of just up, you have to add the "set platform vector X" too.

  • Very nice!   Problem is though that he will only be knocked back in the Same direction no matter where he is hit.   

    To fix that you could ether do what Encryptedcow said above , or add a condition saying

    If player is not mirrored > set enemy platform vector x = 200.   

    If player is mirrored > set enemy platform vector x = -200

    I'll be using physics for my knockback though. So I'm in a different boat

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