JacobV
Member
So for my game, I have an enemy type that hunts down the player, and upon establishing a line of sight charges towards them. So far, everything is working fine; except for the AI which actually pursues the player. I've tried various methods; starting with mp_potential_step, which was stupid and choppy. Then I moved to grid-based AI, which has various problems itself; they will only move in the 8 base directions, and tend to overlap into what looks and acts like one entity.
I'd like to use grid-based, but what I have so far doesn't cut it and I am very new to coding top-down AI. Anyone have any ideas on how I can fix these problems?
I've attached some of my code to help.
I'd like to use grid-based, but what I have so far doesn't cut it and I am very new to coding top-down AI. Anyone have any ideas on how I can fix these problems?
I've attached some of my code to help.
Code:
// Creation Event
path = path_add();
pos = 1;
xx = path_get_point_x(path,pos)
yy = path_get_point_y(path,pos)
Code:
// Step Event
xx = path_get_point_x(path,pos)
yy = path_get_point_y(path,pos)
if instance_exists(obj_player)
{
mp_grid_path(grid,path,x,y,obj_player.x,obj_player.y,1)
path_set_kind(path, 1);
turn(point_direction(x,y,obj_player.x,obj_player.y)+90,13) // This is to handle the image angle, has no impact on the actual movement
motion_add(point_direction(x,y,xx,yy),1)
}