Dany24
Member
hello, I am creating a tower defence type platformer and I have had problems to make a good enemy that enemy has to destroy different objects(walls, doors, player) before reaching the "nexus"(main objective)the problem I have is to make the enemy move and stop near the target and destroy it and then continue with the next one I appreciate your help, it is the last thing I need to fix to finish the development.
This is the search code, but what I don't know is how to apply it to a horizontal platform movement. I have used other types of object movements but never the platform movement with gravity and AI jumps.
GML:
///event create
objective[0] = obj_nexus;
objective[1] = obj_Bdoor;
objective[2] = obj_Pplayer;
var tar = argument0; // Always the first set target
var bar = instance_nearest(x,y,obj_nexus)
var list = ds_priority_create(); //Create a priority list
if distance_to_object(bar) < 16 {
tar = bar;
}else {
for (var i = 0; i < array_length_1d(objective); i++) { //Loops through all objectives
ds_priority_add(list,objective[i].id,distance_to_point(objective[i].x,objective[i].y)) //Adds the objects and distances | Compares them
}
tar = ds_priority_find_min(list) //Returns the closest objective
}
return tar;
Last edited: