Have AI move to the closest of 3 different objects

Hey @DigitalSketch!

Sure you can!

You can do a Multi Sphere trace for Objects of a good distance, searching for any objects of those types, and then it will output an array.

From there, use a ForEach loop with that array as an input, getting the object location minus the AI’s location. Then use get vector length, and then add that float to an array of floats using Array: Add. (This array needs to be cleared with Array: Clear before the Sphere trace).

Once you’ve done that, you can use the “MinOfFloatArray” node to get the index of the float that is lowest. This index will match the index of the Multi Sphere Trace for Objects output.

Now, you can use that index number on your Multi Sphere Trace for Objects output array with a “Get: A Ref” node, and there you have it! The closest shield, health regen, or health bonus pickup object. :slight_smile:

If you have any further questions, let us know!