Jump to content

Using NavMeshes

Recommended Posts

How limited are our abilities to play with Nav-Meshes?


I can tell an entity to use one and be told whether its possible or not and as far as I know thats pretty much it.


Can Nav-Meshes be targeted functionally?


I was trying to see if I could use Camera::Pick() to know when the mouse was over a Nav-Mesh. I can have half the solution in that I can tell if the returned position is within a Nav-Mesh but I cannot guarantee that the Pick() will choose the surface with the Nav-Mesh

Share this post

Link to post

I create a pivot which I move to the point indicated and use GoToPoint() to the same location, if the return is true its in the navmesh, if false it isn't I then immediately use Stop()

Share this post

Link to post

Clever. I like it.


I think the function you're then looking for is Camera::Project. It'll give you the screen coordinates of the pivot. If your check is true and the coordinates match the coordinates of the mouse, your mouse is over a navmesh.


You can also kind of use World::Pick (with points "before" and "after" your pivot) to get the entity that the navmesh is on. I say kind of because navmeshes aren't exact so your pick line needs to be long enough to cover this. And the longer it is the more of a chance that it'll grab another entity than the one you're looking for. So it's a balancing act. However, you can set collisiontypes so that should help too.


I hope that made sense. Let me know if not.

Share this post

Link to post

Its the other way around at present, I'm starting with screen co-ordinates rather than 3D space.


I'm currently using Camera::Pick() to get the location at which to place the pivot. Then I do the test to see if its NavMesh usable. A pick has one of three results, no intersection, first intersection or closest intersection. If the map has a complex topography, think multiple bridge spans to go over or under then being able to pick the correct part becomes very difficult. I'm already restricting collisions to scene rather than scene + props for the test. For now the solution is to be careful with level design but I'd like to be able to drop that limitation.


I had a look at the World::Pick() function and think I have the gist of what you are saying, create a tangential line through the scene to see which piece of geometry might be the best fit. I'm not sure if it adds any new info but I'll go experiment with it to see if I can reveal something.

Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...