S
space fable
Guest
HI,
i have a game with a lot of objects with pathfinding.
Some objects can go in the same coordinate x, y.
When first object come in coordinate x,y, the other object change "target" and go in other coordinate x,y.
The problem is sometimes when the first coordinate x,y are busy when the other objects go in the other cooridnate, the objects don't stop in the coordinate, have strange moviment and sometimes also sprite change and is not the right sprite.
that's my script:
In OBJECT CONTROLL:
In create:
In OBJECT ENEMY
In CREATE:
in END STEP:
in STEP:
sprite have different size but every sprite is more small than cell grid
i have a game with a lot of objects with pathfinding.
Some objects can go in the same coordinate x, y.
When first object come in coordinate x,y, the other object change "target" and go in other coordinate x,y.
The problem is sometimes when the first coordinate x,y are busy when the other objects go in the other cooridnate, the objects don't stop in the coordinate, have strange moviment and sometimes also sprite change and is not the right sprite.
that's my script:
In OBJECT CONTROLL:
In create:
Code:
global.grid=mp_grid_create(0,0,room_width/73,room_height/93,73,93);///create grid
global.busy =0 //check if some coordinate are empty or not
In OBJECT ENEMY
In CREATE:
Code:
path=path_add();
zona=2; //when this is 2 follow the pathfinding
image_speed=0.1;
Code:
if global.busy=0
{
mp_grid_path(global.grid,path,x,y,1460,744,true);
}
if global.busy=1
{
mp_grid_path(global.grid,path,x,y,1460,651,true);
}
if global.busy=2
{
mp_grid_path(global.grid,path,x,y,1460,558,true);
}
if global.busy=3
{
mp_grid_path(global.grid,path,x,y,1460,465,true);
}
if global.busy=4
{
mp_grid_path(global.grid,path,x,y,1460,372,true);
}
if global.busy=5
{
mp_grid_path(global.grid,path,x,y,1533,744,true);
}
if global.busy=6
{
mp_grid_path(global.grid,path,x,y,1533,651,true);
}
if global.busy=7
{
mp_grid_path(global.grid,path,x,y,1533,558,true);
}
if global.busy=8
{
mp_grid_path(global.grid,path,x,y,1533,465,true);
}
if global.busy=9
{
mp_grid_path(global.grid,path,x,y,1533,372,true);
}
path_start(path,3,"" ,1);
switch point_direction(xprevious, yprevious, x , y) {
case 0: sprite_index = sprite47; break;
case 90: sprite_index = sprite37; break;
case 180: sprite_index = sprite35; break;
case 270: sprite_index = sprite34; break;
}}
Code:
if x=1460 && y=744 && zona=2 //if object is in the first path coordinate....
{
sprite_index= sprite32 //change sprite
zona=20 ///change to be sure objcet don't follow new pathfinding coordinate
global.busy +=1 ///change global for can active the second path for other object
}
if x=1460 && y=651 && zona=2
{
sprite_index= sprite32
zona=20
global.busy +=1
}
if x=1460 && y=558 && zona=2
{
sprite_index= sprite32
zona=20
global.busy +=1
}
if x=1460 && y=465 && zona=2
{
sprite_index= sprite32
zona=20
global.busy +=1
}
if x=1460 && y=372 && zona=2
{
sprite_index= sprite32
zona=20
global.busy +=1
}
if x=1533 && y=744 && zona=2
{
sprite_index= sprite32
zona=20
global.busy +=1
}
if x=1533 && y=651 && zona=2
{
sprite_index= sprite32
zona=20
global.busy +=1
}
if x=1533 && y=558 && zona=2
{
sprite_index= sprite32
zona=20
global.busy +=1
}
if x=1533 && y=465 && zona=2
{
sprite_index= sprite32
zona=20
global.busy +=1
}
if x=1533 && y=372 && zona=2
{
sprite_index= sprite32
zona=20
global.busy +=1
}