Please check if I'm using the Seeker component correctly

  • A* version: 5.3.7
  • Unity version: 6000.0.44f1

I’m working on a 3D open-world game.

In this world, there are environment elements that can be dynamically created or removed at runtime. Enemy objects need to support various types of interaction, including physics using Rigidbody, so I’m trying to control their movement through script instead of using the built-in movement components provided by the A Pathfinding Project (such as AIPath).*

Each enemy object has a Seeker component attached. I use it to get the direction toward the player (specifically, the direction to the nearest point on the path), and then apply force to the Rigidbody in that direction from within the enemy’s script.

However, since the world is dynamic, I assumed that frequent path recalculation would be necessary. So I’m currently calling Seeker.StartPath every 0.2 seconds. In the future, there will likely be dozens of these enemies active at the same time, so I’m concerned whether this is a proper and scalable approach.

Another issue is that I don’t know how to factor in each enemy’s individual size when calculating the path. I saw that there are agent size properties in the A* Pathfinding Project’s singleton settings, but as far as I know, those apply globally to all agents. Is there any way to make the path calculation take into account the specific size of each object when using the Seeker?

regarding the last issue, it seems like the only reliable way to calculate paths based on each enemy’s size is to use multiple graphs

like shown here:

what i was hoping for was a more automatic system — for example, simply adding a component to the enemy that would handle everything and generate correct paths based on its size

but i guess there’s no straightforward way to do that

I think this is a fine start but if you want better scaling, I’d instead only recalculate every maybe 2 seconds maximum, and then if a dynamic item is created too closely then I’d call for another immediate recalculation. That way, you’d be able to set your forced recalculation time pretty high, but only if their path needs to be updated will it actually be updated.

I think I need to know more about your enemies here. Do they pathfind? Do they move at all? And how do players interact with them/how do they interact with players? Multiple graphs is one way to handle this but there are other ways, such as with RVO. I’d need to know more about your needs to suggest something concretely though.

Thanks for the response! Most of the enemies do pathfinding, and I’ve implemented RVO so they can avoid each other. As for dynamic structures in the world—like trees or objects placed by players—I’ve added them as Dynamic Obstacles.

Here’s what I’m wondering:
For an RVO agent to avoid something, that target also needs an RVO component attached. Between attaching RVO components to these dynamic structures vs. using Dynamic Obstacles, which one has less overhead?

I think either path is fine- Aron has done a bang up job with handling performance so I don’t think it really becomes much of an issue until the numbers get really large. You may also want to look into updating graphs during runtime by area which may be a good alternative- you can simply only update the area of a graph that you specify as changed, meaning no numerous obstacles or RVO agents in the first place.

1 Like

super helpful, appreciate it! gonna try out all the approaches you mentioned

1 Like