Navigation, path and multiple points.

Hi all!

I have an question about paths and navigation system. I have a big solid actor, for example wooden barrier. Character can’t move into it center, but can go to any of it side. I am creating four points: one for each side. Now i can find path for each side, using those points. And I can use function “AIController::MoveToLocation”. And all works fine.

Image_2.png

But imagine, that the wooden barrier can move (it is drifts in the water). If I were to use method “AIController::MoveToActor”, the path would change automatically. But in my case path will be static.

So question is: How to chage the navigation system so that it will use multiple points for finding shortest paths to the actor?

Thanks in advance for any information.

By the way, I know about INavAgentInterface, but it is not what I need.

It’s an interesting question and I don’t think the existing nav system provides an easy way to do it.

Short of modifying the engine, I don’t think you can get this behavior in a way that allows you to still use the regular MoveTo functionality. If you’re willing to create your own MoveTo function and always use that one instead, you could do it. Give your actors like these an interface or component with a function that takes a Pawn as input and returns a destination actor. Also have them spawn a placeholder actor (something like ATargetPoint) at each side - easiest might be by adding child actor components. Then implement that function how you like. A simple solution would just return the target point closest to the pawn, a more in depth one would use the nav system to generate a path to each target point, and return whichever had the shortest path.

Your MoveTo function then just tests to see if the target actor has this interface/component - if so, it calls built in MoveTo passing the result of calling the above function; if not, it just calls it passing the target actor itself. Since your target points are attached to the parent actor, the path should update automatically when it moves.

Thank you for the interesting idea with Actors! I will try to realize it. But there is one thing that worry me. There is a possibility of large number of dummy actors in the scene. I think, it is necessary to create dummy actor only when path was found and character was started moving.

Yep, might be possible, although knowing when they can be cleaned up may be tricky.
I think so long as you ensure you use an actor with no primitive components and no ticking, the overhead should be minimal. Good luck!