Jump to content

Nav mesh questions


Guppy
 Share

Recommended Posts

To keep the GUI project from growing too abstract I had the idea of making a toy city game for my son where he can place down tiles with roads/grass/houses/traintracks and then put cars, trains and people in that will run around randomly. Seems fun and deceptively simple, but one thing I can't quite figure out is how to keep the cars on the road, the train on the track and let people walk on the pavements and cross the road.

 

This lead me to two questions;

  1. Can I have multiple navigations meshes? ( on each for cars,trains and people )
  2. how would each tile share what parts belongs to various navigation meshes?

For 2) I'm thinking of making multiple collision meshes to cordon off the areas that are off limits, of course this depends on 1 being possible. But the documentation leads me to believe it is not, if it indeed is not how would you go about it?

System:

Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k

Link to comment
Share on other sites

Though there is only one navmesh per world, I believe you can make multiple worlds, and so as many navmeshes as worlds created. So I'd create a world/navmesh for the trains, world/navmesh for the cars and world/navmesh for the people. In your case it sounds like this will require varying collision meshes (as people can go everywhere and cars can cross tracks). Should be interesting to implement.

 

Note that there will be a major lag when the navmeshes are recalculated (as calculation is slow) so you'll want to do that once the tiles are finished being placed (gameplay will need to stop).

Link to comment
Share on other sites

The whole thing is effectively a tile system right?

 

Taking roads as an example I'd create a 2D binary array and every time I add a road location I set that tile to true. That way I only need worry about whether or not a vehicle can cross a tile boundary in a specific direction. So If I were travelling east at Roads[x, y] then I can continue if Roads[x+1, y] is true else I'd have to decide which way to turn.

 

Same with trains and people. You can also imply some stuff too Roads[x,y] == true and Trains[x,y] == true means level crossing while Roads[x,y] == true and People[x,y] == true means pedestrian crossing.

 

Then its about adding the unit level AI to use the arrays

 

 

content over form, game play over all.

Link to comment
Share on other sites

You can create tiles with prebuilt waypoints. The road waypoint has a key saying its a road, the sidewalk has a waypoint saying its a sidewalk. Cars only look for car waypoints and people look for sidewalks. The complicated part is getting the car to plot a path from a location to another exclusively using waypoints.

Link to comment
Share on other sites

Einlander and randomkeyhits: Is it possible to do this with the navmesh and pathfinding system built into Leadwerks though? I mean, you would essentially be having to program A* or something just for selecting the waypoints. That being said, that's probably the way to go for a tile-based game like Guppy described.

Link to comment
Share on other sites

Yeah it seems like the sensible solution would be to make a grid based A* implementation, would've been nice to just have the engine solve it tho ^^

System:

Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k

Link to comment
Share on other sites

As there is only the single navmesh you couldn't easily use it for multiple purposes if the requirements of the mobiles were different. In Guppy's case its to keep the roads and pavements separate.

 

As part of a tile system, each tile could have a (or even more than one) pivot attached. That way the actual movement becomes a GoToPoint on a GetPosition of the selected pivot. Its a case of how much of the AI gets baked into the map vs how much is computational under the mobiles.

content over form, game play over all.

Link to comment
Share on other sites

What I do for my own game is using the navmesh as a base for where movement is possible. Then I create my own layers of walkable areas on top of that (both waypoint and grid).

When you look in to the recast repository it is actually not that common to make severall navmeshes. I also would have though this was something common but apparently this isn't the case.

Link to comment
Share on other sites

To be honest I'd love to be able to create my own shaped plain and designate it as a navmesh, being able to tailor something exactly for a scene is quite a powerful tool. Especially if I'm using several different meshes. This would mean extending the navigation commands though.

content over form, game play over all.

Link to comment
Share on other sites

I thought that once the navmesh was generated, it could be updated realtime without much conflict. Such as, in the editor adding another navigation obstical would cause that area of the navmesh no longer reachable. I thought you could observe this in the editor. Been a while so i may be wrong.

bool Life()
{
 while(death=false)
 {
   if(death==true)
   return death;
 }
}

 

I have found the secret to infinite life

 

Did I help you out? Like my post!

Link to comment
Share on other sites

I thought that once the navmesh was generated, it could be updated realtime without much conflict. Such as, in the editor adding another navigation obstical would cause that area of the navmesh no longer reachable. I thought you could observe this in the editor. Been a while so i may be wrong.

 

Perhaps in 3.0 but since 3.1 its no longer real time, unfortunately.

Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)

Link to comment
Share on other sites

If I'm not mistaken, with the C++ version of Leadwerks, you can access recast functions directly and do threading, so you can recompute a small region of the navmesh instead of the whole thing. Personally, I would like to see these functions exposed to Lua. When I bought the engine, I had thought that dynamic pathfinding was a part of it due to a few dev videos that showed it, but I guess that was an earlier version like Olby said.

  • Upvote 1
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.
Note: Your post will require moderator approval before it will be visible.

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.

 Share

×
×
  • Create New...