How to calculate custom pathfinding for custom Pawns?

Hi everyone, I’m developing a little tank minigame and I want to add artificial intelligence to enemy tanks. I have run into a little problem with the tank finding its way through Unreal’s pathfinding efficiently. And Google has not taken me anywhere that really helps me with the problem.

The tanks that I use vary a little in size each one, but all are characterized by being wide on the Y axis. To find my way around obstacles on the ground I call the “Find Path to Location Synchronously” function. This function gives me a path, but all the generated points are very close to the test walls that I have given as an example.

As you can see in the following image, in “pathfinding context” I have added the tank’s Pawn in case in this way the function calculated the points according to the tank’s dimensions, but the result was the same.

Currently my tank moves according to physics, that is, I move it as if it were the Unreal Engine vehicles but with my own functions in my own blueprints, so I do not use any type of component of movement as characters and vehicles do. In addition, so that it moves properly and does not cause problems, the root of the blueprint is an empty “scene component” and the movement of the tank is carried out by the “skeletal mesh” through the colliders of the same. I don’t know if this will influence the size calculation with the navigation path.

It is the first time that I make such a specific artificial intelligence and with these conditions. Is there a simple trick with which I can make the route points further away from the walls / obstacles and calculate wide routes where the tank can pass without problems? For example, avoid passing between two buildings very close together and do not give him space to pass.

I apologize for the poor English. If you have any questions about it or you want me to clarify any questions about my problem, ask me.

Are you using a NavModifier component on the walls to make the navmesh either “null” or “obstacle” where the walls are? If you are using just static meshes for walls you will need to make it an Actor so you can add the component.

The NavModifier needs collision on the walls to work, so make sure you have the bounds defined. If you want the tank to stay further from the walls then you can increase the collision bounds so the wall make a bigger footprint on the navmesh.

Set the NavModifier to Obstacle would probably work best.

Hi Jon, thanks for the advice, I have been doing quite a few tests for my project and you have helped me a lot. Aside from using tanks in my game, I had planned to add infantry and medium and small vehicles, so I will use the different costs that you can add to each area so that each one fits more or less to each obstacle.