if obj_player.x != x
image_xscale = sign(obj_player.x - x);
if obj_player.x < x
sprite_index = spr_enemy_left;
else if obj_player.x > x
sprite_index = spr_enemy_right;
thanks. still if boss will face player then it will go to direction where the boss faced.Put this in the step or end step event of the enemy object:
and make sure the x origin of the sprite of the enemy is centered.Code:if obj_player.x != x image_xscale = sign(obj_player.x - x);
You could alternatively also use this if you have separate sprites for facing right and left:
Code:if obj_player.x < x sprite_index = spr_enemy_left; else if obj_player.x > x sprite_index = spr_enemy_right;
You mean you also want to change movement towards where the enemy or boss faces?thanks. still if boss will face player then it will go to direction where the boss faced.
if obj_player.x != x
image_xscale = sign(obj_player.x - x);
hspeed = image_xscale * 4;
if obj_player.x < x {
sprite_index = spr_enemy_left;
hspeed = -4;
} else if obj_player.x > x {
sprite_index = spr_enemy_right;
hspeed = 4;
}
You mean you also want to change movement towards where the enemy or boss faces?
Then do this:
or this:Code:if obj_player.x != x image_xscale = sign(obj_player.x - x); hspeed = image_xscale * 4;
and change 4 to whatever speed the enemy/boss should have.Code:if obj_player.x < x { sprite_index = spr_enemy_left; hspeed = -4; } else if obj_player.x > x { sprite_index = spr_enemy_right; hspeed = 4; }
no like the one pic I show youSo, like this?
I'm not entirely sure what you mean.Code:if obj_player.x != x image_xscale = sign(obj_player.x - x); hspeed = clamp(hspeed + image_xscale * 0.1, -4, 4);
Ok, the picture makes it clear, but the code I gave should do that already.
What goes wrong?
//turn...............................................................
hspeed = image_xscale;
if cam_player.x < x {
spd = -0.1;
} else if cam_player.x > x {
spd = 0.1;
}
So, is the issue solved?well I figured it out when your away then found some
the sprite suppost to face the player
Code://turn............................................................... hspeed = image_xscale; if cam_player.x < x { spd = -0.1; } else if cam_player.x > x { spd = 0.1; }
I solved my issue, but what is still bothering me is boxesSo, is the issue solved?