Hi all -
I hope there are some people here that are familiar with this game engine and its scripting feature. I have also posted a request for assistance on the Game Maker forums, but it seems to be pretty slow over there so I'm branching out here as well. I will update appropriately when things get fixed.
- - - - -
To start, I will say that currently my code 'works', as it will move my character along the path and snap him to the grid at the end of the path. The problem is that when he moves horizontally, he dips down about 16 pixels and then goes back up at the end. The same happens for vertical movement - he dips out to the right 16 pixels and goes back at the end of the path.
My grid is created and the path variable defined in a 'grid controller' object in its Create event:
globalvar grid;
globalvar path;
grid = mp_grid_create(0, 0, (room_width / 32), (room_height / 32), 32, 32);
mp_grid_add_instances(grid, obj_Wall, 1);
path = path_add();
The movement is tied to my character object, on a 'Global Left Released' mouse event:
if mp_grid_path(global.grid, global.path, round(self.x div 32) * 32, round(self.y div 32) * 32, round(mouse_x div 32) * 32, round(mouse_y div 32) * 32, 1)
{
path_start(global.path, 16, 0, 1);
}
My game uses 32x32 sprites and tiles. The character sprite has its origin at (0, 0) because if I put it at the center (16, 16) it becomes visually obvious that it's not lined up to the game grid. But even if I force it to spawn in the middle of a tile, it still moves erratically - actually even more so than with the origin at (0, 0).
One thing I have noticed is that if I change the first two values in the 'mp_grid_create' function from '0, 0' to '-16, '-16', my character no longer dips when he moves. However, this causes collision issues when I add the 'obj_Wall' objects into the grid in the next command. Drawing the grid shows that with the '-16, -16' values set, the wall objects fall into 2 mp_grid grid spaces and thus my character will have spots where he cannot enter a grid because part of it is considered a wall, even though it's actually a floor tile.
Is there anything I can do to get my character to stop dipping when he moves while also keeping my grid in line with my tiles?
Thank you for any assistance,
Antonymity