Jump to content

Navmesh


Hodo33

Recommended Posts

I can't find much info on the navmesh tool. I have a bot in the nav area but not sure of any script commands I can give it to spawn, shoot, chase or hide. I saw a couple videos on setup and testing but nothing about how to use it in game.. any help or pointers ?

Link to comment
Share on other sites

  • 4 months later...

I got the navmesh to build and I can run the bot around, works fine.

Question is I have an aiPlayer I created, how do I make this bot associate or know about the navmesh?

I call %bot.findNavMesh() and it returns -1 I note in the c++ the line

"Get the NavMesh object this AIPlayer is currently using" I dont see how to make my aiPlayer "use" this navmesh. How do I point my ai to the mesh?

Link to comment
Share on other sites

Quote from code I use in Uebergame, it is a move command, that works with and without NavMesh, the Bot will check if a NavMesh is existing and if so uses the NavMesh and if not uses a fallback no-NavMesh navigation system.


I would recommend to use an AI system such as BadBot which I use, otherwise you have to code your AI yourself, which is not that hard for the basics, but a framework makes things easier.

 

// moveTo command, %dest can be either a location or an object
function BadBot::moveTo(%obj, %dest, %slowDown)
{
  %pos = isObject(%dest) ? %dest.getPosition() : %dest;

  if ( %obj.getNavMesh() ) 
  { 
     %obj.setPathDestination(%pos); //setPath uses navMesh
  } 
  else 
  { 
     %obj.setMoveDestination(%pos); //old function wihtout navMesh
  } 

  %obj.atDestination = false;
}

 

Fell free to rip off my implementation.

Link to comment
Share on other sites

Well I got it mostly working. I discovered you have to do navmesh.build() when the game loads.

I notice in the navmesh description the line vehicles = "0"

I changed that to a 1 rebuild and the bots still collide with any vehicle. Any way around that ?

thanks for your help by the way, checked out your game, impressive...

Link to comment
Share on other sites

You don't have to do navmesh.build or whatever, the navmesh is build in the navmesh editor and then saved to a file. The navMesh is not dynamic, it is build once and then used that way as rebuilding it would cost too many resources and take too long. Only thing you can do is rebuild parts of the navmesh, which can happen fast enough, I have seen this in a demo from the user @Azaezel in his game, where he used it to rebuild the navmesh around characters, so they do not get stuck. In my game I do not bother with it that much, since the bots are usually dead before they can get stuck, additionally I have a push function so you can push other players out of the way which helps also.

Link to comment
Share on other sites

Ok starting to make more sense. I made the navmesh and it saves in my mission file is that what you mean? If so it wont work unless I do a build at load time. I can get in edit mode and tell my bot to follow me and it works fine but in game it tells me there is no valid mesh

Link to comment
Share on other sites

Yeah after I get in game I do a build, tell the bot to follow me and all is well.

I never touched any of this code, first time I tried to use it.

I do get alot of spam on this:

No contours in rcContourSet for NavMesh 21533

Is there a depth issue with this object? like if I place it right on the surface or slightly below ?


Sorry to be such a pain....

Link to comment
Share on other sites

  • 2 months later...

@Code_Man no need to debug the Navmesh, since it works fine, you "only" have to debug your implementation of whatever you try to do.


In the Navmesh editor there is even a button to spawn a test bot and you can direct him around, then you can see how well the Navmesh works, so that is proof that it works.

Link to comment
Share on other sites

  • 3 weeks later...

Well navmesh works better now that I altered a few things. I have a situation where I have 3 nav meshes but only one should be active per mission so I load the proper one for the mission. Changes I was making did not save properly so I have taken to adding the mesh to the mission, do a build, then delete the saved one, save the game and it all updates properly. During the mission I load the proper mesh out of the mission file and everything seems to work ok now. Thanks for all your help...

Link to comment
Share on other sites

  • 4 months later...

Ok back to this. I don't know if this is the right way but it works. I find when I edit the mesh it won't over write the levels/zone.nav so I delete that file, edit and save the game, all is well. Navmesh works fine at this point.

I had a question before about my character driving a vehicle into the area and the bots collide with it and you said "Only thing you can do is rebuild parts of the navmesh, which can happen fast enough" ... Can you tell me how to rebuild parts around where the vehicle sits. Seems if I move the vehicle within the mesh and jump out I have to do a instant rebuilt ?

Thanks for any help

Link to comment
Share on other sites

@Code_Man I'd double check, but setPathDestination is specifically for path nodes which is different to setMoveDestination which is a pathless command to set the destination of the AI, it is the latter command that uses the navmesh.


@Hodo33 I think Az is pointing out that you can update smaller parts of the navmesh in a more dynamic fashion (runtime, particularly id, expect without looking in more detail), a full rebuild isn't really warranted apart from probably when doing more development work on a level, i suspect the documentation posted by steve will help muchly in this regard :)

Link to comment
Share on other sites

right. sorry. yeah. to use a script example from our objective-doors:


 

function staticshapeData::onOpen(%this,%obj)
{
  NavmeshUpdateAll(%obj,false);	//false = ignore for cutout purposes, true = include
}

 

the second links there as an alias cause the first methods got a fairly unintuative name, so likely deprecate that at some point.

Link to comment
Share on other sites

I used the NavmeshUpdateAll and the NavMeshUpdateOne got in the editor and there is no clear area around the vehicle, same with hovercraft

I open the editor and where it is blue the bots can walk. After calling this update it is still blue and bots still collide.

The vehicle has a collision on it and I did a getWorldBox to make sure that was valid as well... any ideas ?

Link to comment
Share on other sites

Got it in but not sure it's working properly. First off I use 3.8 ..and called NavMeshUpdateAroundObject. In my version the function didn't have a reference to mPathfindingIgnore in sceneObject.cpp / h so I added that but I can make the call and it returns. Not sure if the "ignore" is the only equate for that. Anyhow here is a link to a pic. I drive the vehicle in and make the call on exit and you can see the result ... http://www.hyperkat.com/Images/navmeshIssue.jpg


Since this function checks worldbox and a vehicle box is off the ground because of the tires and the bot reference is on the ground do you think this might be an issue?

If something protruded from a wall at waist high the bot will run into it? Or the octree checks for any path obstruction in vertical from worldbox on bot player.?

Link to comment
Share on other sites

Join the conversation

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

Guest
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...