### Navmesh

Scripting questions, discussions, etc

#### Navmesh

Hodo33
Posts: 104
Joined: Fri Dec 29, 2017 4:34 pm
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 ?

#### Re: Navmesh

Steve_Yorkshire
Posts: 335
Joined: Tue Feb 03, 2015 10:30 pm

Originally the nevmesh was a 3rd party resource before the author was nice enough to open source it. Here's the original documentation on how it works.
http://yorkshirerifles.com/random/Walka ... tation.zip

#### Re: Navmesh

Duion
Posts: 1552
Joined: Sun Feb 08, 2015 1:51 am

Well you need to program the AI yourself, the navmesh is just for navigation, but you can use BadBehavior, it comes with a few example behaviors for AI players.

#### Re: Navmesh

Hodo33
Posts: 104
Joined: Fri Dec 29, 2017 4:34 pm
Thanks for the reply. I will have a look at these things. I have developed my own AI system and thought the navmesh was a A* technology for moving the bots around.

#### Re: Navmesh

Hodo33
Posts: 104
Joined: Fri Dec 29, 2017 4:34 pm
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?

#### Re: Navmesh

Duion
Posts: 1552
Joined: Sun Feb 08, 2015 1:51 am

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.

Code: Select all

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

#### Re: Navmesh

Hodo33
Posts: 104
Joined: Fri Dec 29, 2017 4:34 pm
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...

#### Re: Navmesh

Duion
Posts: 1552
Joined: Sun Feb 08, 2015 1:51 am

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.

#### Re: Navmesh

Hodo33
Posts: 104
Joined: Fri Dec 29, 2017 4:34 pm
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

#### Re: Navmesh

Duion
Posts: 1552
Joined: Sun Feb 08, 2015 1:51 am

I have no idea what you did, the NavMesh works by default, you do not have to do anything, so if you broke it, you have to tell us how you broke it, or reset to a clean working build.

#### Who is online

Users browsing this forum: No registered users and 1 guest