J
Joao Cruz Malhao
Guest
Im still fairly new to gml and I've been messing around with basic AI hunger systems (want to create somekind of simulation with a basic ecosystem, pig eats plant, wolf eats pig and from those source code can create variety of animals), currently i have a hunger variable value that decreases each second, and once it hits a certain value, pig_obj moves towards grass_obj. but i hit a stop when tried to get to the instance_nearest and continue off to the next nearest instance and so on. instead pig_obj just doesnt move.
here's the STEP EVENT code:
rest of the code seems to be working fine but ill insert here just in case.
CREATE EVENT:
ALARM[0]:
DRAW:
COLLISION >< WITH GRASS_OBJ:
any help or tips would be much appreciated.
here's the STEP EVENT code:
Code:
grass.x = instance_nearest(x,y,grass_obj).x
grass.y = instance_nearest(x,y,grass_obj).y
if (pig_hunger < 50) {
move_towards_point(grass.x, grass.y, 5);
}
else {
pig_speed = 0;
}
rest of the code seems to be working fine but ill insert here just in case.
CREATE EVENT:
Code:
pig_health = 100
pig_hunger = 100
pig_stamina = 100
pig_thirst = 100
pig_speed = 5
alarm[0] = room_speed;
Code:
pig_hunger -= 10;
pig_thirst -= 10;
alarm[0] = room_speed;
Code:
draw_text(20, 20, pig_hunger);
draw_text(20, 50, pig_thirst);
draw_self();
Code:
pig_hunger += 50
instance_deactivate_object(grass_obj);
Last edited by a moderator: