Viciousse
Member
Hi everyone,
I am trying to add an "AI" dodge of player bullet; with the following:
- Enemie can move right or left to avoid bullets
--- Move left if there is no obstacles (other enemies or other instances) otherwise move right if possible.
- Most important: Dont go toward bullets
- Bullet can bounce a few times
I am using the code bellow, but its not working as i was expecting:
Is there any better way doing this other then "distance_to_object"?
I am trying to add an "AI" dodge of player bullet; with the following:
- Enemie can move right or left to avoid bullets
--- Move left if there is no obstacles (other enemies or other instances) otherwise move right if possible.
- Most important: Dont go toward bullets
- Bullet can bounce a few times
I am using the code bellow, but its not working as i was expecting:
GML:
move_wrap(true, false, sprite_width);
if (distance_to_object(obj_ball) < 150) {
if (distance_to_object(obj_robot) < 50) {
sprite_index = spr_robot_right;
x += 1;
} else {
sprite_index = spr_robot_left;
x += -1;
}
} else {
sprite_index = spr_robot;
}
Last edited: