Download

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 spaaaaaace 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.

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.

(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 spaaaaaace. 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 spaaaaaace and on each tick re-order them to move to that location (converted to world spaaaaaace).

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?

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.

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.

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