"Knockback" on player hit

0 favourites
  • 7 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Hey there guys! I'm currently working on a pretty simple side scrolling fighting game (think Streets of Rage, Golden Axe, Castle Crashers etc) and i've hit a bit of a problem. The main character has three hit points, and each time you take damage i've managed to make the character fade out for a half second, but one thing I really wanted to do was to make it so once you took a hit, you jumped backwards a bit.

    I did have something working with a weird bit of Player.X(-40) coding or something similar (I don't know the first thing about coding, haha) but it didn't work. I feel like i'm missing something simple, but any help would really be appreciated!

    5ifty2wo.co.uk/Ghostwiz2/index.html

    This is the current very barebones testing version that I threw together just to show a friend, but i'll put it here just in case it helps at all.

    (arrow keys move, A is attack, all you can do at the moment is run, jump, kill, and die)

    Thank you for any help you can give me!

  • should be quite straight forward....

    player on collision with enemy

    enemy.x > player.x

    -->

    player.x = player.x - 10

    player.y = player.y - 10

    EDIT:

    quick example: dl.dropbox.com/u/45711709/knockback.capx

  • I couldn't use your example file (says I need construct 1.8 and I only have 1.4) but I managed to get it working thanks to what you posted, so thank you!

    Would you happen to know a way to make the player fly backwards, rather than just jumping instantly? I can use this just fine, but it would be useful to know for future reference :)

  • Well, upgrade to 1.8 then :D

    scirra.com/construct2/releases/r118

    Install it to a seperate folder if you don't like beta's

    and ofcourse i can make him fly backwards instead:

    dl.dropbox.com/u/45711709/knockback2.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Use time delta to maintain mobile performance

    player.x = player.x - 100 * dt

    player.y = player.y - 100 * dt

  • Well, upgrade to 1.8 then :D

    http://www.scirra.com/construct2/releases/r118

    Install it to a seperate folder if you don't like beta's

    and ofcourse i can make him fly backwards instead:

    https://dl.dropbox.com/u/45711709/knockback2.capx

    Ah this is perfect! Thank you so much! :D

    Exactly what i've been looking for. At the moment it was so easy to get chain hit to death, but with this hopefully it'll make it easier on the player. I'm a complete newbie to this all so i've just been trying random stuff that I feel should work but didn't, haha. Thanks again!

  • I tend to use player vector instead of directly setting player.X Also, you can use the flash behavior which may look a bit better than a fade...

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