How would I go about finding the closest game object by tag?

fotoshopt 4 years ago updated by Ryan DowlingSoka 4 years ago 3

In C#, I would just build a collection of each game objects, iterate through them, compare their distance between "self" and "target", then return the closest game object.

I've been trying to solve this one for two days. I'd really love to use this plugin but it seems like the most simple tasks are so difficult for some reason. 


Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):

You should be able to do it exactly the same way as in C#.

(Put this inside of a macro.)

Or you can take this package I just made for it:

Alternatively you can make the function in C# and just call it directly after updating your unit options. :) For things that are pretty simple but take some structure I tend to go to C# because I'm more comfortable there.

Basically anything you can do in C# you can do in Bolt, it just might be more verbose feeling. So merging the two can be really great.

This is great. Thank you for this. After I posted the question last night I realized that creating a custom unit may be the way to go so went ahead and learned how to do that.

I've not used visual scripting in the past, but a project I'm working on pretty much requires a visual state machine as it's getting unmanageable. I still making sense how to best utilize this plugin. Creating Bolt graphs feels like I'm figuring out a puzzle, I guess it becomes more intuitive?


Some of the fuzzy finder improvements in future versions will help, but yeah. The best thing to do since you have the experience is maybe to think of it as just writing code. I would switch away from the Human Naming if you are more comfortable with the C#. Good luck!