Troubles with Bridges

I did not notice this bug until very recently but the NavMesh.SamplePosition returns a point only on the terrain. Not on objects like bridges. So even though the player and enemies can traverse the bridge, the player cannot stop on the bridge or click on it due to something. I spent a good long time trying to debug this and I am at a loss.

The NavMesh is baked to the bridge, but when hovering the mouse over the bridge, I get the cursor for none and cannot move the character and stop on the bridge. This problem also extends to platforms.

I tried changing the maxNavMeshProjectionDistance to something larger like 5 and I can stop on the bridge but then the player stops at a large offset from the position to directly above the terrain (or water in this case) and not on the mouse position.

From my debugging attempts, I believe the problem is at the NavMesh.SamplePosition()

I appreciate any help I can get on this. Thank you!

Does your bridge have a collider on it? The Physics.Raycast relies on colliders, and will completely ignore meshes, meaning that the raycast will go through a bridge without a collider and likely onto a position that is not on the navmesh.

That was the fix, embarrassed but an important lesson. I must have read over that thinking I had it on since the player could walk over it. At least its a simple fix and a lesson to read the documentation slower. Thanks again for the help Brian!

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

Privacy & Terms