aggro range and sight | gml
objPlayer Step
x += (keyboard_check(vk_right) - keyboard_check(vk_left))*3; y += (keyboard_check(vk_down) - keyboard_check(vk_up))*3; move_bounce_all(true); //lazy way to do collisions
objCreeper Step
var in_range = false; // CHECK IF PLAYER IS WITHIN AGGRO RANGE OF 100 PIXELS OF CREEPER: if (distance_to_object(objPlayer) <= 100){ in_range = true; } var can_see = false; // GET ANY INSTANCE OF A WALL BETWEEN MY SELF (CREEPER) AND PLAYER: if collision_line(x,y,objPlayer.x,objPlayer.y,objWall,false,true) == noone { can_see = true; } //--------------------------------------------------------------- //collision_line( x1, y1, x2, y2, obj, prec, notme ); //^^ prec = per-pixel collisions, true = slow! //^^ notme = exclude instance calling the function (if relevant) //--------------------------------------------------------------- if (in_range and can_see) { direction = point_direction(x,y,objPlayer.x,objPlayer.y); speed = 2; } else{ speed = 0; } move_bounce_all(true); //lazy way to do collisions