I'm playing around with direct movement for porting my (2D) game to consoles. Controlling the player works, but getting him to stay within the navmesh is not happening.
The manual suggests that it should be doable, but when I change pathfinding method in scene settings (as suggested here https://www.adventurecreator.org/tutorials/unity-navigation-pathfinding) to Unity Navigation, AC tells me that "This method is not compatible with 'Unity 2D' mode".
Sticking 2D colliders outside all the navmeshes doesn't feel like a solution as I got tons of them in the game I'm porting. Any alternative way to accomplish this?
Thanks
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Unity Navigation pathfinding is only available for 3D scenes, and so the use of the baked NavMesh to limit direct-control is only avaiable for 3D games. I shall make this more clear in the Manual.
In 2D, you might be able to get by with checking if the character is on the NavMesh each frame, and move them to the closest point on it if not, e.g:
Cool, I might use that technique for a future game👍