Navmesh

Scripting questions, discussions, etc
  • 1
  • 2
14 posts Page 1 of 2
Hodo33
Posts: 42
Joined: Fri Dec 29, 2017 4:34 pm
by Hodo33 » Thu Mar 22, 2018 5:37 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 ?
Steve_Yorkshire
Posts: 294
Joined: Tue Feb 03, 2015 10:30 pm
 
by Steve_Yorkshire » Thu Mar 22, 2018 6:10 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
Duion
Posts: 1102
Joined: Sun Feb 08, 2015 1:51 am
 
by Duion » Thu Mar 22, 2018 6:27 pm
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.
Hodo33
Posts: 42
Joined: Fri Dec 29, 2017 4:34 pm
by Hodo33 » Fri Mar 23, 2018 12:43 am
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.
Hodo33
Posts: 42
Joined: Fri Dec 29, 2017 4:34 pm
by Hodo33 » Mon Jul 23, 2018 5:47 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?
Duion
Posts: 1102
Joined: Sun Feb 08, 2015 1:51 am
 
by Duion » Mon Jul 23, 2018 6:25 pm
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.
Hodo33
Posts: 42
Joined: Fri Dec 29, 2017 4:34 pm
by Hodo33 » Tue Jul 24, 2018 1:48 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...
Duion
Posts: 1102
Joined: Sun Feb 08, 2015 1:51 am
 
by Duion » Tue Jul 24, 2018 3:30 pm
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 @
User avatar
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.
Hodo33
Posts: 42
Joined: Fri Dec 29, 2017 4:34 pm
by Hodo33 » Tue Jul 24, 2018 11:18 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
Duion
Posts: 1102
Joined: Sun Feb 08, 2015 1:51 am
 
by Duion » Wed Jul 25, 2018 12:32 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.
  • 1
  • 2
14 posts Page 1 of 2

Who is online

Users browsing this forum: No registered users and 0 guests