B
BigLaw Games
Guest
Hey, I'm working on a platforming shooter. Currently I'm trying to get enemies to shoot the player automatically. I found some really good code on this form that should work. However, it only shoots one bullet after the enemy dies after the death animation plays.
I want it to work where he shots the player when he is in range automatically, not after when the enemy dies. The step event code is below. Any help is greatly appreciated.
hsp = dir * movespeed;
vsp += grav;
// Enemy Shooting
max_range = 300
range = distance_to_object (obj_player)
if (range <= max_range)
{
bullet1 = instance_create(x,y,obj_enemy_bullet)
bullet1.direction = point_direction(x,y,obj_player.x,obj_player.y)
bullet1.image_angle = bullet1.direction
bullet1.speed = 5
}
// Hit Points & Dealth
if (hp == 0)
{
instance_change(obj_enemy_dealth,false);
}
Thanks
Derek
I want it to work where he shots the player when he is in range automatically, not after when the enemy dies. The step event code is below. Any help is greatly appreciated.
hsp = dir * movespeed;
vsp += grav;
// Enemy Shooting
max_range = 300
range = distance_to_object (obj_player)
if (range <= max_range)
{
bullet1 = instance_create(x,y,obj_enemy_bullet)
bullet1.direction = point_direction(x,y,obj_player.x,obj_player.y)
bullet1.image_angle = bullet1.direction
bullet1.speed = 5
}
// Hit Points & Dealth
if (hp == 0)
{
instance_change(obj_enemy_dealth,false);
}
Thanks
Derek