D
DarthTenebris
Guest
Hello everybody,
I am currently trying to make my game's enemies, and I thought I'd start from the most basic enemy, a simple kamikaze enemy. Unfortunately it turns out it isn't as simple as I thought, particularly when it comes to their behavior.
The circles are the enemies, the box on the left is the spawner, and the box on the right is the target. The player is the tank. This grid is drawn by the function mp_grid_draw(), and it's making me wonder.
1. Why is the grid uneven? All objects are 64x64, center origin, while the grid is 32x32, to make sure a 64x64 can be placed a bit more freely instead of just on the center of a 64x64 grid.
The code above is located in the create event of the enemy object.
2. The main problem is that the enemy can't pathfind through the gaps, even though it obviously fits. Why is that, and how would I fix that?
3. I've tried the other mp_* functions but the grid is the one that gave me the most progress. The manual says the grid is the most costly. Could I use the other mp_* functions to achieve my goal? I plan on adding "smarter" enemies, that could try to avoid the player, or instead rush past the player, etc. but for now a kamikaze enemy would do. The obstacles generally don't change, not planned for now at least.
Thank you for your time.
I am currently trying to make my game's enemies, and I thought I'd start from the most basic enemy, a simple kamikaze enemy. Unfortunately it turns out it isn't as simple as I thought, particularly when it comes to their behavior.
The circles are the enemies, the box on the left is the spawner, and the box on the right is the target. The player is the tank. This grid is drawn by the function mp_grid_draw(), and it's making me wonder.
1. Why is the grid uneven? All objects are 64x64, center origin, while the grid is 32x32, to make sure a 64x64 can be placed a bit more freely instead of just on the center of a 64x64 grid.
Code:
grid = mp_grid_create(0, 0, room_width / 32, room_height / 32, 32, 32);
mp_grid_add_instances(grid, obj_wall, false);
path = path_add();
if (mp_grid_path(grid, path, x, y, obj_target.x, obj_target.y, true)) {
path_start(path, 0, path_action_stop, false);
}
2. The main problem is that the enemy can't pathfind through the gaps, even though it obviously fits. Why is that, and how would I fix that?
3. I've tried the other mp_* functions but the grid is the one that gave me the most progress. The manual says the grid is the most costly. Could I use the other mp_* functions to achieve my goal? I plan on adding "smarter" enemies, that could try to avoid the player, or instead rush past the player, etc. but for now a kamikaze enemy would do. The obstacles generally don't change, not planned for now at least.
Thank you for your time.