user27191
user27191

Reputation: 11

problems with C# Port of Recast Detour Navigation Mesh for XNA, A* Pathing

Update 10/03

Ok, so i figured out the problem. C# is a funny old language..I changed

    int navMeshCount = navMesh.GetPath(ref start, ref end, routePolys, navMeshRoute, false);

to

    var navMeshCount = navMesh.GetPath(ref start, ref end, routePolys, navMeshRoute, false);

and finally im getting the pathfinding values to work!

When i debug the routeNavMesh array fills up with the values i require.

https://i.sstatic.net/skJBu.png [Screencap of debug in question]

Ill update again once im done.


Having some major problems getting a navigational mesh to work, in particular i cant get it to do any pathfinding or get it to respond to my vector3 input in any useful way.

Im working on the sunburn engine, it sits on top of XNA 4.0, so all of XNAs functions are still usable.

Recently Recast Navigation from digesting Duck's blog was ported over to c# and i've used it to create navigation meshes for my levels. Here is a link to the tutorial/guide i've been trying to follow: http://xboxforums.create.msdn.com/forums/p/109484/647991.aspx

im not sure how to pass in the start and end values on the getpath segment, are these meant to be values in world space or object space or something? If i do vector3 values and enter them as the start and end values( and then subsequently set them in a place on the array), i dont get an array of values that shows path finding, i just get those two verbatim values inside the navmeshroute array.

Here is where i try and run the path, its in my Update.

        routePolys = new ushort[dtStatNavMesh.MAX_POLYS];
        navMeshRoute = new Vector3[dtStatNavMesh.MAX_POLYS];


        if (ks.IsKeyDown(Keys.L))
        {

            if (!runOnce)


            {
                start = new Vector3(0, 0, 0);
                end = new Vector3(1000, 0, 1000);
                ppos = x;

                navMeshRoute[0].X = start.X;
                navMeshRoute[0].Y = start.Y;
                navMeshRoute[0].Z = start.Z;

                navMeshRoute[count].X = end.X;
                navMeshRoute[count].Y = end.Y;
                navMeshRoute[count].Z = end.Z;


                int navMeshStart = 0;

              navMesh.GetPath(ref start, ref end, routePolys, navMeshRoute, true);


                Console.WriteLine("navMeshPC" + navMesh.getPolyCount());

                int navMeshCount = navMesh.GetPath(ref start, ref end, routePolys, navMeshRoute, true);

                while (navMeshStart < navMeshCount)
                {

                    routeNode = navMeshRoute[navMeshStart++];

                }



                Console.Out.WriteLine("NMc : " + navMeshCount);

            }
        }

Upvotes: 1

Views: 1091

Answers (0)

Related Questions