Big moving object. (Train)


I have got big moving object in my scene, to be more precise it is a train with wagons. I’m using recast graphs.
Do you have any suggestions how to do pathfinding in this situation.

Pathfinding for other units not for a train naturally.



Depends on your game mechanics. But at least initially I would go with a rectangular navmesh cut for the train and it’s wagons. Preferably with quite a bit of margin.



But is it possible to recreate navmesh after cutting or will it leave a trail of chopped navmesh after my moving train ?



The navmesh cut component works perfectly well with moving obstacles. Take a look at the video on that page I linked. Internally it saves the original navmesh and re-cuts it every time an obstacle moves.


Yes I just saw it, I will try it. Thank you.


Works almost like a charm :).

I got two issues with it. And one small suggestion.

First you cannot specify what graphs are going to be cut, you have to cut all of them.

Second after cutting there is a space between wagons that is smaller than a radius of a characters but pathfinding is still guiding throught this little space.

My suggestion would be to add additional condition for cutting, not only distance but also time. When the body have not crossed the distance for a specified time it could make a cut anyway. This would enchence precision when the body stops close to the distance condition. Naturally cuts only once when no changes to body position.



Yeah. Currently it is only possible to disable or enable navmesh cutting for a whole graph (there is a toggle in the recast/navmesh graph settings). However you cannot set which graphs a navmesh cut updates.

The navmesh is defined as the surface for which it is safe for the center of the character to be on. So your navmesh cuts should be expanded by the character radius already. Just increase their width by 2x the character radius. I am considering adding a checkbox for automatically expanding the navmesh cut based on the field in the recast graph settings though.