#AI path not working:

7 messages · Page 1 of 1 (latest)

manic musk
#
//Parent NPC End Step Event
if (path_next_point > 0 and x = path_point_x and y = path_point_y)
{
    path_next_point++
    
    if (path_next_point >= path_get_number(path))
    {
        path_next_point = 0
    }
}```
#
//Left Click Event
var _target_x = tile_to_room(room_to_tile(mouse_x) + 0.5)
var _target_y = tile_to_room(room_to_tile(mouse_y) + 0.5)

move_to_point(_target_x,_target_y)```
#
//Controller Object Create Event

collision_tile_map = layer_tilemap_get_id("Collisions")

var _grid_width = room_to_tile(room_width)
var _grid_height = room_to_tile(room_height)

global.NPCgrid = mp_grid_create(0,0,_grid_width,_grid_height,TILESIZE,TILESIZE)

for (var _x = 0; _x < _grid_width; _x++)
{
    for (var _y = 0; _y < _grid_height; _y++)
    {
        var _collision = tilemap_get(collision_tile_map,_x,_y)
        
        if (_collision) 
            mp_grid_add_cell(global.NPCgrid,_x,_y)
    }
}```
#

Im pretty sure the problem is here:

if x_input!=0
     y_input = 0```
#

but if I remove it, the npc starts walking diagonally, which I dont want

manic musk