P
Patrik Grinsvall
Guest
Since i solved my orignial question which was creating a new path in each step event (dont know why it only affected a few enemies, but sitll good).
I go directly to the :
*BONUS QUESTION*
The manual says about mp_grid_path
However i have always used absolute coordinates and not coordinates divided by cell size. Anyone know the answer to this? It would be really buggy if the xgoal and ygoal was coordinates and not pixels.
Any ideas?
I spawn 5 enemies at x = 0. Their y are random. They all use pathing and here is the relevant code:
Spawning code:
Code that creates the path (create of enemy1):
Now to the problem. Only some of the enemies move. All have their path layed out but they just refuse to move...
See attached screenshot. The red tiles are impassable tiles. The lines are the paths and i have marked what objects are moving and what is not. I have also tried to set a fixed speed to 2 and a bunch of other things even removing all obstacles from the game. Still same result.
I go directly to the :
*BONUS QUESTION*
The manual says about mp_grid_path
Code:
mp_grid_path(id, path, xstart, ystart, xgoal, ygoal, allowdiag);
x start Starting x coordinate of the new path
y start Starting y coordinate of the new path
xgoal Finishing x coordinate of the new path
ygoal Finishing y coordinate of the new path
Any ideas?
I spawn 5 enemies at x = 0. Their y are random. They all use pathing and here is the relevant code:
Spawning code:
Code:
// if it is time to spawn the enemies.
if(time == spawn_time && enemies_alive == 0) {
// spawn enemies
for(tmpx = 0; tmpx <= spawn_amount; tmpx++) {
var randomy = irandom_range(0, window_get_height());
randomy = irandom_range(0, window_get_height());
var tmpinstance = instance_create_depth(1, randomy, 100, o_enemy1);
}
// increase difficulty...
level++;
spawn_amount = spawn_amount + level;
enemy1_hp = enemy1_hp + (level * 2);
enemy1_speed = enemy1_speed + (level / 10)
enemy1_attack_damage = 10 + (level*2);
}
Code:
if(instance_exists(nearestInstance)) {
myPath = path_add();
mp_grid_path(global.grid, myPath, x, y, nearestInstance.x, nearestInstance.y, true);
path_start(myPath,2, path_action_stop, true);
show_debug_message("we have a path!");
} else {
show_debug_message("we dont dont 1! have a path!");
}
See attached screenshot. The red tiles are impassable tiles. The lines are the paths and i have marked what objects are moving and what is not. I have also tried to set a fixed speed to 2 and a bunch of other things even removing all obstacles from the game. Still same result.
Attachments
-
113 KB Views: 3
Last edited by a moderator: