How i can make my tank find nearest target

I wan’t to make my tank find nearest enemy[target] and set it to nill when it’s out of range

I tried youtube pathfinding, but it’s not that i’m wan’t

I wan’t a suggestion where to start and what to use

I’d say get the position of your tank, and the position of the enemy. Then, subtract them and get the difference like so:

(tank_pos_here - enemy_pos_here).Magnitude

Store them all in an array and the one with the smallest magnitude is the closest one.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.