0
\$\begingroup\$

In Unity, I'm trying to get the raycast to hit the navmesh only, but I cannot find an option to place navmesh on a specific layer.

Is there a way to raycast to the navmesh itself?

\$\endgroup\$
6
  • \$\begingroup\$ Can you explain what you're trying to accomplish? The navmesh is not a physics object visible to raycasts, but we might be able to implement the feature you have in mind in a different way. \$\endgroup\$ Commented Apr 27, 2021 at 20:56
  • \$\begingroup\$ That is an answer enough. Thank you. \$\endgroup\$ Commented Apr 27, 2021 at 21:07
  • \$\begingroup\$ You can fire a "navigation ray" along the navmesh to see if it hits a boundary, or find the closest point on the navmesh, or the nearest edge from a point on the navmesh - are any of those what you're looking for? For the benefit of future users, I'd like to get this question to a place where we can post a more useful answer than "no". \$\endgroup\$ Commented Apr 27, 2021 at 21:21
  • \$\begingroup\$ NavMesh.Raycast() sounds like what you want. Have you tried that yet? \$\endgroup\$ Commented Apr 27, 2021 at 21:53
  • \$\begingroup\$ Yeah, I looked into navmesh Raycast. The objective is to sample the navmesh without a ray terminating against things like walls. The Nav ray mentioned above would still suffer from the limitations expressed in the post, unless I am misunderstanding it's function. \$\endgroup\$ Commented Apr 27, 2021 at 21:55

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.