Hi, I have a moving train that I want some people to walk out of when it pulls into a station, but is it possible to have a NavMesh in the moving train?
So although you cant currently bake navigation to dynamically moving objects, you should be able to setup a work around for what you need. Maybe try this…
*Go to Navigation > Areas and add an area (Call it something like “Train”).
*Now in your scene move the train GameObject to its destination where the people will walk off.
*In Navigation > Object select the train and set its navigation area to “Train”, and Navigation Static checked.
*You should now be able to bake your navigation Navigation > Bake and select the bake button on the bottom.
*Select all Navmesh agents, and goto area mask and uncheck the “Train” so it can not be used, since we only want the agents to be able to walk on this area when there is a train in place.
*Reset your train GameObject to it normal starting position and uncheck navigation static.
*Next will require a bit of coding. Use a trigger collider on the train tracks that will be hit right as the train reaches its destination. OnTriggerEnter find all the Navmesh agents that will be entering or exiting the train. with all of these agents we will now get the area mask and check the “Train” area to checked. set the agents destination and they should walk off or on the train.
*When or if the train leaves just uncheck all the agents “Train” Area again, so we don’t have people walking in mid air over the train tracks.
Hope that helps.
@JBR-games Thank you for that full explanation, I was already moving the train to the station an baking the NavMesh but did not think about area masks, thank you that will work great.