Get all entities around a radius

Hi Guys,
I’m trying to implement the A* pathfinding algorithm but to do that I need to build a grid and I need the coordinate position of all entities present in a radius. How can I do that? Maybe using trigger?

Really wish there was a box version of this function, that way we could line it up with things, with a sphere there is a cut off if you try to line it up, say at the bottom of the character’s feet.

You could conceivably ghetto it with a trigger.

Alternately build your own function, populate an array with FindObectsWithTag() or similar method and google about for one of the myriad of bounding box tests for use in collision detection.

As far as I’m aware, OverlapSphere currently uses the collider bounds, which is an axis-aligned box.

Quietus:
Yeah I have ghettoed it with a trigger so to speak, it is really expensive. Unless you know of an easy way to find a point or transform.position within the area of a box that is less expensive than creating an array within the collision functions I am welcome to hear it. I suppose I might be able to use this:

AdamStarks:
As far as I see what is documented, it checks against the bounding boxes of colliders but the area it checks within is a sphere not a box.

That’s essentially what I was alluding to in my previous post. There’s dozens of different methods for checking aabb overlap. Just search google for “box overlap algorithm” or something similar.

But you still need to assemble a group of objects to query against so you’re back to square one. And in the end, you are essentially for the most part simply replicating what a trigger or the first step in detailed collision detection does under the hood.

You mentioned this was intended for building a navmash, and that’s usually something that’s done pre-execution where the performance isn’t that big of an issue. Or am I missing something?

There are other projects you might want to look at for ideas. For example some of the community RTS projects have code where you select units by drawing a box. They might perhaps have a different take on the problem that would be better for your case.

Actually this …

… is exactly what works, I simply ask to see if a transform.position is in the bounds of the trigger and it does what I want and is not that expensive at all.

You are right though, you need to know what entities you are looking for in the trigger or have a list of all of them you can iterate to see which ones are in there. But that is not that difficult at all to do.

Actually I was not really looking to build a navmesh simply just trying to see what objects are in a trigger without having to use the collision code. I cannot call the collision code when I need it from another script (as far as I know anyway) so this is another way around it.

^^ This. This right here. This makes my life so much easier! Thank you! Now I don’t need to add unnecessary colliders to my objects I’m searching for!