S
stepup2000
Guest
//step step
var view_distance = 800;
var tx = x+lengthdir_x(view_distance,direction);
var ty = y+lengthdir_y(view_distance,direction);
if (collision_line(x,y,tx,ty,obj_player,true,false)) {
if (collision_line(x,y,obj_player.x,obj_player.y,obj_wall,true,false)) = noone {
state = 2
}
}
else {
state = 1
instance_destroy(obj_interest_point)
instance_create_depth(obj_player.x, obj_player.y, 1, obj_interest_point)
}
// begin step
if state = 2 {
image_angle = point_direction(x,y,obj_player.x, obj_player.y);
mp_potential_step(obj_player.x, obj_player.y, 1, false)
}
}
if state = 1 {
speed = 0
}
i want the enemy to follow the player when he is looking directly at the player and there is no wall in between them. but for some reason it doesnt work. state = 2 is chasing the player
var view_distance = 800;
var tx = x+lengthdir_x(view_distance,direction);
var ty = y+lengthdir_y(view_distance,direction);
if (collision_line(x,y,tx,ty,obj_player,true,false)) {
if (collision_line(x,y,obj_player.x,obj_player.y,obj_wall,true,false)) = noone {
state = 2
}
}
else {
state = 1
instance_destroy(obj_interest_point)
instance_create_depth(obj_player.x, obj_player.y, 1, obj_interest_point)
}
// begin step
if state = 2 {
image_angle = point_direction(x,y,obj_player.x, obj_player.y);
mp_potential_step(obj_player.x, obj_player.y, 1, false)
}
}
if state = 1 {
speed = 0
}
i want the enemy to follow the player when he is looking directly at the player and there is no wall in between them. but for some reason it doesnt work. state = 2 is chasing the player
Last edited by a moderator: