With help from the gamemaker discord they came up with this, Global left click is the same as the demo file, on the Global right click i added follow_path = true
if follow_path = true{
var points_array = path
if array_length(points_array) = 0{
speed = 0}
else{
if point_distance(x,y,points_array[0,0], points_array[0,1]) > walk_speed{
In order to do precise tile collisions it would require a navmesh system, the A* is a grid based system and only handles navigation with rectangular collisions. I will look into it and see what I can do.
← Return to asset pack
Comments
Log in with itch.io to leave a comment.
Im new when it comes to custom A* Pathfinding. How do i get an object to follow the created path/array ?
when i add path_start(path,3,0,0) it says ""path_start argument 1 incorrect type (array) expecting a Number""
do it like this (make sure you delete path when done with it):
var path_array = ap_grid_path_array(obj_tester.grid, x, y, mouse_x, mouse_y);
path = path_add();
for(var i = 0; i < array_length(path_array); i++){
var point = path_array[i];
path_add_point(path, point[0], point[1], 1);
}
path_start(path, 3, path_action_stop, 0);
With help from the gamemaker discord they came up with this,
Global left click is the same as the demo file, on the Global right click i added follow_path = true
if follow_path = true{
var points_array = path
if array_length(points_array) = 0{
speed = 0}
else{
if point_distance(x,y,points_array[0,0], points_array[0,1]) > walk_speed{
move_towards_point(points_array[0,0],points_array[0,1], walk_speed) }
else{
x = points_array[0,0]
y = points_array[0,1]
array_shift(points_array) }
}
}
This works really well!Are you going to do pathfinding system working with tilesets?
Sounds like a good future update for this asset. Something like ap_grid_add_tile_layer(...)? And mask out specific tile ids as walls
Something like this. I can recommend You Pixelated pope's collision tutorial: https://gamemaker.io/en/blog/precise-tile-collisions-by-pixelated-pope -You can check it for precision reference.
In order to do precise tile collisions it would require a navmesh system, the A* is a grid based system and only handles navigation with rectangular collisions. I will look into it and see what I can do.
This looks good, can’t wait to try it out!