Pathfinding on a moving object / Local space pathfinding

So I’m looking to implement pathfinding on a moving object. Imagine a train or a ship or something like that. I implemented this in unity by transforming back and forth between local and world space when looking up where to go. That way I didn’t have to recalculate the navmesh as the ship was moving. In UE4 however, it seemed to be even easier at first glance. I took the approach of parenting the navmesh to my blueprint-based ship.

Right now, this is working okay-ish but there are a couple of issues of varying importance.

  1. I can’t seem to make the NavMeshBoundsVolume be a part of the blueprint. I would like for it to be a component so it’s spawned together with the blueprint. Instead I have now resorted to spawning one manually in the scene and parenting it to my blueprint. This seems like a possible duplicate of the question asked -here- , I just thought I would mention it.

  2. (This is the biggest issue I’m having) Ordering a pawn through an AIController with MoveToLocation, will cause it to path towards a point in world space. Now imagine I order my pawn to go to the middle of my ship. While it’s pathing there, I move the entire ship away. Suddenly, the middle of my ship is somewhere else and my pawn is pathing to some point outside the ship. I’m wondering if there’s a good way to solve this. A very hacky solution would be to keep track of their target position in local space and on each tick re-order them to move to that location (converted to world space).

  3. I’m not sure what’s happening right now since I’m not completely sure what navmesh options I have set up, but ideally I don’t want the navmesh to update. The objects inside the ship are static and there’s no reason to update the navmesh just because the ship is moving. Is it possible? If not, will having to remake several navmeshes for different ships all the time as they move around have a noticable impact on performance and/or pathing?

  4. This is more of an observation: I started out with the third person template and have been modifying it a bit. My characters didn’t use to stay on the ship when I moved it but now they do. They aren’t parented to the ship-blueprint but when I move the ship, the characters move with it. This is what I want, I just don’t understand why it’s happening.

I’m really hoping what I want is possible, in some way or another. It really is a core mechanic in my game.

1 Like

To add to this, it seems like the navmesh isn’t replicating properly. I’m not sure if there’s a way to turn on navmesh replication, although that’s not really what I want.

Since I have the navmesh attached to my blueprint-based ship in the scen and the ship is replicated, I thought the navmesh would follow the replicated ship properly when the ship moves. This doesn’t seem to work however.

When I try running a dedicated server, the navmesh stands still on the client I tried ejecting mid-game and looking at the navmesh position and it appears not to have moved. It also failed to path to places where the navmesh should have followed after moving.

Currently navmesh on moving platforms is not supported, but it’s really high on our priority list, so stay tuned (but don’t hold your breath! :wink: ).
Regarding navmesh replication, it’s not being replicated at all. Currently navmesh is present only on the server, by design. There are plans to load navmesh on clients as well, but that will be working reliably with static navmesh, unless you’re willing to take the risk of navmesh differing between server and clients (which is fine if you just need it for information purposes on clients for example).



Edit: Nevermind. The issue below was completely my fault and had nothing at all to do with the navmesh. In case someone is interested, I had a stupid check to see if the player arrived at their location which was basically: if (targetPos.X < 0). So it didn’t go to places if they were below the platforms origin in X value.

Great! Thanks for the information. I guess I can do some workarounds for now. I have another similar navmesh issue that I ran into: I worked around the other problems by making a huge navmesh and having it rebuild during runtime.

The rebuilding works great if I move the platform forward, but if I rotate it, a part of it is no longer walkable, even though I used the console command “Show navigation” to confirm that the navmesh is rebuilt.

Here’s some pictures showing the problem. picture 1, picture 2

In the first picture, the platform hasn’t moved and the character can walk all the way to the edge. In the second picture, the platform has rotated around the bottom left corner using AddActorWorldRotation. As you can see, the navmesh updates but I still can’t walk on the red triangle.

This is running with one player and no dedicated server.

@MieszkoZ : is “navmesh on moving platforms” still high on the priority list? Any updates or ETA?

An update about this would be greatly appreciated. Right now i Have a big vehicle moving around the world, and i need the AI to move around this vehicle. Any ideas is this is achievable ?

@MieszkoZ An update about pathfinding on moving actors or a way-around would be perfect. Apparently you mentioned that it`s in your top priorities list in 2015, hello from 2018 :slight_smile:

I would like to know how you got navmesh to attach to a moving actor. That would solve my problem where the entire floor of my maze level rises and the navmesh keeps getting invalidated because of the encroaching floor.

any update on this ?

Hi from 2021. Hows that pro

Hello from 2022! Any updates?

come on guys it is a critical thing for gameplay and still not any update

Still no update on this? Seems like a pretty critical thing that most people want.

1 Like