Hi, noob here
I have a problem with programming knocback in my platform game. I tryied everything and it still not working well. My goal is easiest smooth knocback when collide with enemy depend on direction of enemy object. Any idea how to do that?
Heres my "movement core", maybe it would help
I have a problem with programming knocback in my platform game. I tryied everything and it still not working well. My goal is easiest smooth knocback when collide with enemy depend on direction of enemy object. Any idea how to do that?
Heres my "movement core", maybe it would help
GML:
key_left = keyboard_check(ord("A"));
key_right = keyboard_check(ord("D"));
key_jump = keyboard_check_pressed(ord("W"));
key_climb = keyboard_check(ord("W"));
var move = key_right - key_left;
hsp = (move * walksp)
vsp =vsp + grv
// jump
if(place_meeting(x,y+1,o_Wall)) and (key_jump)
{
vsp = -7;
}
//climb
if(place_meeting(x,y,o_Lina)) and (key_climb)
{
grv = 0;
vsp = -4;
}
grv = 0.3;
//horizontal
if(place_meeting(x+hsp,y, o_Wall))
{
while(!place_meeting(x+sign(hsp), y, o_Wall))
{
x = x + sign(hsp);
}
hsp = 0;
}
x = x +hsp;
// vertical
if(place_meeting(x,y+vsp, o_Wall))
{
while(!place_meeting(x, y+sign(vsp), o_Wall))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y +vsp;
Last edited: