J
JustNoa_
Guest
Hi. I have knockback for the player and the enemies in my game, but If the enemy attacks the player, he gets knockback but after that he is staying sliding away very slow. Any solutions?
Please post your code, o we won´t know how to help you.Hi. I have knockback for the player and the enemies in my game, but If the enemy attacks the player, he gets knockback but after that he is staying sliding away very slow. Any solutions?
In that code there´s no knockback movement (not adding speed to the player), I need to see that part. Also, when is it supposed to stop? When the alarm[1] event runs?code for doing damage and knockback to the player:
///Damage the player
if (state != scr_enemy_stall_state) {
var dir = point_direction(other.x, other.y, x, y);
var xdir = lengthdir_x(1, dir);
var ydir = lengthdir_y(1, dir);
var damage = instance_create(other.x+xdir, other.y+ydir, obj_damage);
damage.creator = id;
damage.knockback = 1;
state = scr_enemy_stall_state;
alarm[1] = room_speed;
}
Don't use physics. Check this tutorial and try to understand it.@RichHopelessComposer I'm not copying code, I'm following a tutorial serie on youtube.
Btw. found the code for knockback
var dir = point_direction(x, y, other.x, other.y);
var xforce = lengthdir_x (knockback, dir);
var yforce = lengthdir_y (knockback, dir);
with (other) {
physics_apply_impulse(x, y, xforce, yforce);
}