Is there a way to make a character go backwards when hit? I cant figure out a way to program this.
Is there a way to make a character go backwards when hit? I cant figure out a way to program this.




It depends largely on the engine that you've already got programmed.
You would need to store the number of pixels to knock back (horizontally) in an alterable value, check this and move the player on every cycle of the event list, and reduce the value gradually to zero. The same would go for the vertical axis.
Sometimes the recoil is not a good idea. Like I remember when I used to play CastleVania on my old NES, it used to get really irritating in the second stage when those pushy Medusa Heads would butt you into a pit every single time. They were difficult to effectively attack and often seemed too agile to maneuver around. I rather like a hit effect such as might be seen in the NES classic, Punch Out!!, where it might show his eyeballs bulge out, etc.
[]It depends largely on the engine that you've already got programmed.
You would need to store the number of pixels to knock back (horizontally) in an alterable value, check this and move the player on every cycle of the event list, and reduce the value gradually to zero. The same would go for the vertical axis. [/]
Could you be a bit more specific on how to do this? Im still confused.
Use an alterable value of your player character. Let's say you rename alterable value A to "knockback".
Add events:
* "knockback" > 0
then subtract 1 from "knockback"
then set x position of player to x position of player -1
* "knockback" < 0
then add 1 to "knockback"
then set x position of player to x position of player +1
* enemy hits player
then add to "knockback": x enemy - x player
<or alternatively>
* enemy hits player
then add to "knockback": (Abs(x enemy - x player) / (x enemy - x player)) * 5
(will knock player back 5 pixels)
I put this in, but it said there was a syntax error. Are you sure it works?





[]I put this in, but it said there was a syntax error. Are you sure it works? [/]
you can't just copy-paste what random sugested, if you did do that... You have to do all the value setting and positional stuff 'manually'... or maybe you just left a bracket out in your expression...
if you devide object one x value by object 1 x value, you'll always get one. try doing this without the second devider. (I use TGF1. can anybody help me with the "game logic" for a flying back motion? I'm rather curious on this subject myself.)