C
corwin22
Guest
I am making a simple tower defense game where the turret will target whatever enemy is closest, the issue with that is that it is very specific and I want to make it attack the one in the lead of the line how can I do this?
I can track how far they are with path_position so whatever one has the highest of that variable will be the one targeted. the only question is how can I have it find which one has the highest of that variable?
This is the current targeting system if you need it.
I can track how far they are with path_position so whatever one has the highest of that variable will be the one targeted. the only question is how can I have it find which one has the highest of that variable?
This is the current targeting system if you need it.
Code:
if (instance_exists(obj_enemy)) {
target = instance_nearest(x,y,obj_enemy)
if (distance_to_object(target) < firerng) {
AimDir = point_direction(x,y,target.x,target.y)+90
if (canfire = true) {
canfire = false
target.hp = target.hp - atk
tstage = tstage + 1
alarm[0] = firespd
alarm[1] = firespd * 0.15
}
}
}