Bridges issues after navmesh raycasting modification

I have a couple more free assets in my current project and created a scene a tad more complex than what Rick has done so far. Long story short, I have a couple of actual bridges across the water and a couple of catwalks above the walls, made with asset models rather than terrain; the NavMesh handles them correctly.

The player can still walk on them if I manage to click on the terrain in a place where the AI generates a path that uses said bridges/catwalks, but I cannot click on them and it shows the unwalkable cursor when I hover over them with the mouse.

I figured out that the problem is with the MaxProjectionDistance. The problem now is that if I increase it, we’re back to displaying the movement cursor over water and on buildings too, and all the work done in this lesson is for nothing. If I lower the value to a point where water displays the correct cursor again, bridges are affected too again. There’s no sweet spot that works in both circumstances.

Does anybody else have this problem? Ideas for a solution?

While the navmesh works off of model geometry, Physics.Raycast/RaycastAll ignores model geometry completely in favor of colliders.
Adding a collider to the bridge will allow our PlayerController to detect it and then RaycastNavMesh to it properly. It doesn’t need to be a hard collider. A trigger collider should work fine for this (better, so it doesn’t interfere with the NavMesh)

1 Like

Ah, I forgot about the collider for the raycast! Now it works properly, thanks.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms