💬

Community answer

Collected from the ACE community Discord archive. It may be informal or outdated — anyone can edit this page to improve it.

Finding the closest target in an array

📦 MiscUpdated 2 days ago•1 views
Keep a `closesttarget` variable, iterate through the array, and for each entry compare its distance to the current closest: if current distance < closest target…

How would you make the target the closest target?

Keep a `closesttarget` variable, iterate through the array, and for each entry compare its distance to the current closest:

if current distance < closest target distance then closest target = current thing

At the end of the loop the variable holds the closest object. (The radar's built-in distance output exists but was described as unreliable because it does not start unless targets are very close.)

Was this article helpful?

See More

Discussion(0)

No comments yet. Be the first to ask a question!

Have a question? Sign in to join the discussion.