• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker [Solved] path_start object not moving

B

bryann109

Guest
I can't figure out what is wrong with this code. Searched the forum and couldn't find anything related to my situation. Sprites are 64x64 with middle center origin.

First, in the Create event of my controller (oCtrl)...

Code:
global.mpgrid = mp_grid_create(0,0,room_width/32,room_height/32,64,64);
mp_grid_add_instances(global.mpgrid,oWall,false);
Next, when a bot object (oBot) spawns in the room, in its Create event...

Code:
gspeed = 2;
botpath = path_add();
alarm[0] = 1;
gspeed is used as part of path_start(). In oBot's Alarm 0 event...

Code:
mp_grid_path(global.mpgrid,botpath,x,y,160,160,false);
path_start(botpath,gspeed,2,false);
For some reason, oBot refuses to move. Coordinates 160,160 does not have a wall object. Bots can only move to empty cells. I even tried setting room_width and room_height in oCtrl to /64, but I get the same result regardless. Something is preventing oBot from following its given path. But what?
 

rIKmAN

Member
Have you checked that a succesful path is generated?
Does the instance you are trying to move along the path fit completely inside the cell size when placed with it's origin at the centre of the cell, as per the manual?
 
B

bryann109

Guest
Finally figured out the problem. I had wall objects positioned where the player is not supposed to get to but robots spawn in those very places, making it impossible for them to plot a path. So I ended up making two wall instance layers - one for the player and one for the bots. They are moving normally as expected. Thanks anyway. Now if you will excuse me, I'm going to facepalm myself in the corner...
 
Top