MartinK12
Member
I’m building solution for crossroads in my tower defense game. Enemies move on path, once they hit object obj_choose_path they should end this path, choose another path, move to its start and once there start another path.
1. Can’t figure out how to check if they are already on another path_position(0), I also don't want to change enemies speed.
2. Can I use path_speed of the path I just ended as enemy speed to move_towards_point?
EDIT: I figured out better code but still not sure about it
1. Can’t figure out how to check if they are already on another path_position(0), I also don't want to change enemies speed.
2. Can I use path_speed of the path I just ended as enemy speed to move_towards_point?
GML:
if place_meeting(x, y, obj_choose_path) and (path_choosen == false) {
path_choosen = true;
new_path_to_go = choose(path_mm_2); //for testing one path only
new_path_x = path_get_x(new_path_to_go, 0);
new_path_y = path_get_y(new_path_to_go, 0);
move_to_new_path = true;
path_end();
}
if (move_to_new_path) {
if point_distance(x, y, new_path_x, new_path_y) >= path_speed { //can I use path_speed here?
move_towards_point(new_path_x, new_path_y, path_speed);
} else { //we are on new path so just start it? but enemies will jump to path_position(0) depending on position of path? - not sure about this part?
path_start(new_path_to_go, path_speed, path_action_stop, true);
move_to_new_path = false;
}
}
Last edited: