A
A.J. Rich
Guest
Hey guys! ive been working on a platformer recently and i cant for the life of me figure out how to auto-attack enemies (moving quickly to the enemy hitbox point, which is y-16) when the player is near them and a certain key is pressed. below is a beautiful artistic example of what i mean:
heres the code i'm using for attacking right now in the enemies step event:
//enemy collision
if (place_meeting(x,y,obj_BLOB))
{
if (obj_BLOB.y < y-16){
with (obj_BLOB) vspd = -jspd;
hpts -= 1;
if (hpts = 0) {
instance_destroy();
}
}
else{
room_restart();
}
}
all the move_towards_point() and instance_nearest(x,y-16,obj_enemy) stuff ive tried has either caused the player to clip through the ground or flat out crashed the game. Any help would be greatly appreciated. Thank you!
heres the code i'm using for attacking right now in the enemies step event:
//enemy collision
if (place_meeting(x,y,obj_BLOB))
{
if (obj_BLOB.y < y-16){
with (obj_BLOB) vspd = -jspd;
hpts -= 1;
if (hpts = 0) {
instance_destroy();
}
}
else{
room_restart();
}
}
all the move_towards_point() and instance_nearest(x,y-16,obj_enemy) stuff ive tried has either caused the player to clip through the ground or flat out crashed the game. Any help would be greatly appreciated. Thank you!