2D Platformer Knockback

C

ChrisMG12

Guest
I'm using the code from this video,

I tried searching all throughout the internet for a good tutorial for 2d platformer knockback, however the ones i could find allowed the player to move after being hit, or were for other genres of videogames,like topdown shooters.

Could anyone please either provide me an explanation or a tutorial or a simple code for knockback such that the player doesnt get knocked back multiple times in a single period of time, and prevents usage of control while being knocked back.

Thanks, any help would be appreciated, and sorry for the disturbance.
 

TheouAegis

Member
Set a timer when the player gets hit. As long as that timer is counting down, the player can't be hit any more times.

Method 1: When the player gets hit, also set a variable to true so the game knows the player was knocked back. In the player's control code, if that variable is true, exit the event.

Method 2: Use a state machine where the knocked back state is distinct from all the others. Don't include control code inside the knocked back code.
 
C

ChrisMG12

Guest
i set up an alarm, however what should i write in
if(not alarm[0])
{

}

should i write something like place_meeting(x,y,obj_enemy)
hit=true

and if so what should i do for the character to move once he is hit
 
Top