miltonbhowmick
Member
I don't know why my approach is not working perfectly. I have two moving character instance. These are moving in the room by avoid some obstacle instances. When two are close to each other, they will move around each other and go on another path. I was testing my code. Sometimes it fails. Sometimes it works well. Can anyone guide me on this issue?
collision logic of me:
If a moving instance(farmer) gets another instance of farmer object, he will move around and go to another path to reach his destination.
Can someone help me out of this?
THANKS IN ADVANCE
collision logic of me:
GML:
if(instance_number(oObstacle)==0 && distance_to_object(oFarmer)==GameManager.bubble_range){
// geting same object nearest instance
near_farmer = instance_nth_nearest(x,y,oFarmer,2);
if(y<near_farmer)
{
up_obstacle = instance_create_layer(x-30,y+10,"Blocks",oObstacle);
down_obstacle = instance_create_layer(near_farmer.x-30,near_farmer.y+10,"Blocks",oObstacle);
}
else{
up_obstacle = instance_create_layer(x-30,y-10,"Blocks",oObstacle);
down_obstacle = instance_create_layer(near_farmer.x-30,near_farmer.y-10,"Blocks",oObstacle);
}
mp_grid_add_instances(global.rmGrid,oObstacle,true);
with up_obstacle {
alarm[0] = room_speed * 3; // for destroy this obstacle
}
with down_obstacle {
alarm[0] = room_speed * 3; // for destroy this obstacle
}
}
Can someone help me out of this?
THANKS IN ADVANCE