Hi, so I made quite a few advancements:
The basic idea was to add a custom component to the follower entity and assigning the moving platform entity (also a hybrid entity) to its value. The moving platform component references a transformation matrix to the static “fake” navmesh far off like discussed above (I used NavmeshAdd for now, but other stuff like a recast graph are suitable also). A system then uses these components and applies a transformation matrix to the localToWorld value at the end of the simulation. So while the localTransform is running around on the static navmesh, the localToWorld is transformed to real world space. I decided to manipulate the localToWorld, not the gamobjects transform, since I primarly work with ECS anyways and it also seems a bit cleaner.
For enter/exit behavior, I wrote a custom NodeLink helper script (shamelessly copying from Follower Jump Link) that triggers the OnEnterMovingPlatform/OnExitMovingPlatform functions on the agent, but in the end, any trigger (e.g. by raycast or colliders) should also work.
It’s still a bit experimental, but seems to work so far.
A few questions though:
-
For enter/exit nodes, I used NodeLink2. The node points move around with the moving platforms and the graph is automatically updated in almost realtime (the default behavior). How expensive is that in terms of performance? Does it matter if like 100 dynamic NodeLink2 are active at the same time (e.g. multiple entry points for multiple platforms)?
-
The NodeLink2 points need to be quite close to the navmesh. Is there a radius somewhere to widen the search radius? So e.g. if a nodelink point is like 3-5 meter in range of a navmesh, it still counts as enabled?
-
For now I need to clone not only the navmesh to the far off location of the moving platform, but also it’s collider, otherwise the entities will fall through the ground. Any chance to overcome this? I think it’s also related a bit to the ClampToNavmesh/gravity stuff. I admit I don’t really understand that part well. E.g. why does it fall through the ground, when a) the groundmask is set to graph and b) the ClampToNavmesh should prevent this?
-
For now, I need to deactivate updatePosition and updateRotation of the follower entity and set it’s gameobject transform to the localToWorld position and rotation. Arguable the SyncTransformsToEntitiesJob or the other one should use per default the localToWorld position and rotation, not the localTransform. Or is there any particular reason for using the localTransform?
In my real game I use entities directly, so I don’t care, but I have the feeling that the gameobjects transform should always be synced to the localToWorld component -
A minor thing:
NavmeshClipper has an internal function: internal abstract void NotifyUpdated
which prohibits to extend it (I tried to make a class similar to NavmeshAdd). Maybe you could make it public?
I’m on the road next week, but when I’m back, I can share more details of the setup/code. It could be a nice additional example scene for the package if you are interested