if distance_to_object( Obj_player ) < 150 && !collision_line(x ,y ,Obj_player.x ,Obj_player.y ,Obj_wall ,1 ,1 ) {
direction = point_direction(x ,y ,Obj_player.x ,Obj_player.y )
}
Place the code in the step event of your enemy
"Obj_player" can be replaced by any object you want your enemy to go towards
"150" is the max distance the enemy can be until the player is out of sight (Change it as you please)
the arguments for collision_line are: collision_line(x1 ,y1 ,x2 ,y2 , obj ,prec ,notme)
Without the collision_line it looks like this:
if distance_to_object( Obj_player ) < 150 {
direction = point_direction(x ,y ,Obj_player.x ,Obj_player.y )
}
Enjoy



Find content
Not Telling
