A
Alexander Olofsson
Guest
How would I do if I wanted my enemy to come close, and then initiate the attack animation and create a hitbox in front of him? I have a state, but it's really glitchy.
For example, when he gets close to me, he starts drifting super fast, completely skipping the line of code which tells him to stop moving (movespeed = 0. And the animation does not work.
And whilst I'm in the subject, if the enemy damages me, any ways to make knockback?
Code:
if (en_state == 0)
{
if (distance_to_object(obj_player) < 20)
{
state = 1
sprite_index = spr_forestspirit_atk;
image_index = 0.3
movespeed = 0;
hsp = 0;
}
}
var hit = 0
if (en_state = 1) {
if (image_index >= 2) && (image_index <= 3)
{
with (instance_create(x,y, obj_en_hitbox))
{
image_xscale = other.image_xscale;
with (instance_place(x,y,obj_player))
{
if (hit==0)
{
hit = 1;
vsp = -1
hsp = sign(x - other.x) * 10;
image_xscale = sign(hsp);
}
}
}
}
}
And whilst I'm in the subject, if the enemy damages me, any ways to make knockback?
Last edited by a moderator: