What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

NavMesh system guide

Out

Active Member
Joined
Jun 2, 2012
Messages
2,972
Reaction score
13
A navigation mesh is a collection of two-dimensional convex polygons (a polygon mesh) that defines which areas of the environment are traversable by agents.
Better said, a character in game can freely walk around within those areas unobstructed by trees, lava or other barriers that are a part of the environment.
Adjacent polygons are connected to each other in a graph.

If you want to create a navmesh route, (As AB's navmesh doesn't yet cover whole world) you should use the GPS editor.

Navmesh in GPS editor looks like:

There few simple rules:
1) Each navmesh polygon should be a triangle. AB navmesh builder accepts only triangles from gps database file.
2) Each triangle can be marked as Lowdanger\Highdanger\Road\Jump. Those are default set to Lowdanger. Areas with aggro mobs are recommended to be set as Highdanger.
3) You can create offmesh connections with links (Can later be used for one way movements and jumps). Navmesh builder accepts only OffMeshConnection and SingleOffMeshConnection link types!
beIklfEZ
cKOaKb5R

4) When you create your navmesh, you should consider only obstacles (Trees\Rocks\Houses) except all dynamic obstacles.
CWxgAEgG

Dynamic obstacle (all doodads\creatures):
t2bYJ3DR
Static obstacle:
U74pWJYV




After your gps mesh is ready, you should create AB navmesh with AB plugin editor:
Code:
var gps = new Gps(this); //create new GPS
gps.LoadDataBase(@"D:\Games\my_gpsmesh.db3");    //Load gps database
BuildNavMesh(gps, @"C:\navmesh.ABmesh");  // Build navmesh from gps mesh



If action succeded, you'll receive C:\navmesh.ABmesh file, that can be used for navmesh movements:
Code:
LoadNavMesh(@"C:\navmesh.ABmesh"); // load Navmesh
forceNavMeshMovements = true; // enable navmesh movenets for all MoveTo\ComeTo

MoveTo \ ComeTo (AB core functions) will use navmesh movement.


AB Navmesh APIs contains:
public void BuildNavMesh(Gps gps, string meshPath);
public void LoadNavMesh(string meshPath);
public bool forceNavMeshMovements;
public float[] GetNavPath(double sX, double sY, double sZ, double eX, double eY, double eZ);
 
Another would be to guide Russian written , it would be wonderful )
 
Greetings Out!
Can you briefly explain how GetNavPath() could be used?


Thanks,
user
 
Can you briefly explain how GetNavPath() could be used?
Hi, this function will return list of floats of your path. Maybe you want manually calculate path distance, or check something near each point\etc.
Floats array:
[0] = X1
[1] = Y1
[2] = Z1
[3] = X2
[4] = Y2
[5] = Z2
...
[Count-3] = XLast
[Count-2] = YLast
[Count-1] = ZLast
 
Hi, this function will return list of floats of your path. Maybe you want manually calculate path distance, or check something near each point\etc.
Floats array:
[0] = X1
[1] = Y1
[2] = Z1
[3] = X2
[4] = Y2
[5] = Z2
...
[Count-3] = XLast
[Count-2] = YLast
[Count-1] = ZLast


I see, thanks for the explanation.

BTW: I've done some testing using the NavMesh already, its freaking AMAZING! I love it!

Would it be possible to create a MoveTo(X, Y) / ComeTo(X, Y) overload and disregard the Z axis all together? I have a situation where this would be extremely handy, currently I have my own movement methods for this, but would rather use your methods.


Thanks again,
user
 
Hello Out, prompt how to loop the route , such as running in circles.
Add waypoints on the NavMesh (Example: WP01, WP02, WP03) then all you do is:
Code:
    var gps = new Gps(this); //create new GPS
    gps.LoadDataBase(Application.StartupPath+"\\DATABASE.db3");
    LoadNavMesh(Application.StartupPath+"\\DATABASE.ABmesh");
    forceNavMeshMovements = true;

    while (true) {
        gps.GpsMove("WP01");
        gps.GpsMove("WP02");
        gps.GpsMove("WP03");
    }

NOTE: I noticed that the Waypoints seem to need to be <130 meters from each other.
 
Add waypoints on the NavMesh (Example: WP01, WP02, WP03) then all you do is:
Code:
    var gps = new Gps(this); //create new GPS
    gps.LoadDataBase(Application.StartupPath+"\\DATABASE.db3");
    LoadNavMesh(Application.StartupPath+"\\DATABASE.ABmesh");
    forceNavMeshMovements = true;

    while (true) {
        gps.GpsMove("WP01");
        gps.GpsMove("WP02");
        gps.GpsMove("WP03");
    }

NOTE: I noticed that the Waypoints seem to need to be <130 meters from each other.


Thank you for help yet - write a simple script that would look for the nearest character is living a mob , and the approach to it - if the mob was looking for dead next to each mob and went to him, and repeat the action . I will be very grateful :rolleyes:
 
This code was generated to give you an idea of how it can be done, I would not use this code to go hunt mobs because it is extremely simple. Also, to add a good combat mechanic to this code, you would need to alter the structure. I would suggest spending some time reading the API docs, they are very detailed and extremely helpful. http://archebuddy.com/API/






Code:
            // This example increments through static waypoints 1-4.
            // In a real plugin it would be better to use dynamic code, but this is just a basic example of what could be done.
            // This code could be used with WP01 - WP04
            
            var gps = new Gps(this); //create new GPS
            gps.LoadDataBase(Application.StartupPath+"\\DATABASE.db3");
            LoadNavMesh(Application.StartupPath+"\\DATABASE.ABmesh");
            forceNavMeshMovements = true;
            
            int wpCount = 1;
            while (true) {
                // Get a list of creatures in the area, it would be better to test to see if they are in a navmesh zone, this could be done by creating a method.
                List<Creature> listCreatures = getCreatures()
                                                    .Where(c => isAlive(c))
                                                    .OrderBy(c => c.dist(me))
                                                    .ToList();

                if (listCreatures.Count() > 0) {
                    // Select the closest mob
                    Creature thisTarget = listCreatures.FirstOrDefault();

                    // Set the target
                    SetTarget(thisTarget);

                    // Move to the Creature selected
                    MoveTo(thisTarget);
                } else {
                    // Set the wpCount to the next path
                    if (wpCount >= 5) {
                        wpCount = 1;
                    } else {
                        wpCount++;
                    }

                    // Move to the Waypoint
                    gps.GpsMove("WP"+wpCount.ToString("D2"));
                }
            
                // Let some time pass
                Thread.Sleep(100);
            }
 
Code:
var gps = new Gps(this); //create new GPS
gps.LoadDataBase(@"D:\Games\my_gpsmesh.db3");    //Load gps database
BuildNavMesh(gps, @"C:\navmesh.ABmesh");  // Build navmesh from gps mesh
This code crash Archebuddy on BuildNavMesh
 
Builded navmesh.ABmesh. Load. Set forceNavMeshMovements = true
But MoveTo still running on a straight line. MoveTo(me.target.X, me.target.Y, me.target.Z,true);

Скомпилил navmesh.ABmesh. Load. Установил forceNavMeshMovements = true
Все равно при MoveTo бежит по прямой. Не огибает препятствия. MoveTo(me.target.X, me.target.Y, me.target.Z,true);
 

Attachments

builded navmesh.abmesh. Load. Set forcenavmeshmovements = true
but moveto still running on a straight line. Moveto(me.target.x, me.target.y, me.target.z,true);

Скомпилил navmesh.abmesh. Load. Установил forcenavmeshmovements = true
Все равно при moveto бежит по прямой. Не огибает препятствия. Moveto(me.target.x, me.target.y, me.target.z,true);

Обновите ab, вчера вечером была обнова навмеша.
 
is there a way to open meshes which are already in AB?
There is a catalog but i have no idea what is there inside:P
 
I don't think you can edit it after its compiled can you? ie you make it and add points etc then compile it. i would imagine you would need the orig db3 file to view and or edit it? I could be wrong though. And if this is true we will never have a real navmesh system since each plugin will want to use its own points so using same navmesh for all won't work and each plugin will need its own. Correct me if i am wrong?
 
Back
Top