C#重建绕道导航网格的问题,XNA,A *路径

时间:2013-03-09 06:11:35

标签: c# xna navigation path-finding a-star

更新10/03

好的,所以我想出了问题所在。 C#是一个有趣的旧语言......我改变了

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

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

最后我将获得路径查找值!

当我调试routeNavMesh数组时,填满我需要的值。

http://i.imgur.com/QgH8UL6.png [有问题的调试的Screencap]

我做完后会再次更新。


让导航网格工作有一些重大问题,特别是我不能让它做任何寻路或让它以任何有用的方式响应我的vector3输入。

我正在研究晒伤引擎,它位于XNA 4.0之上,因此所有XNA功能仍然可用。

最近从消化鸭子博客的重新定位导航被移植到c#,我用它来为我的关卡创建导航网格。以下是我一直试图遵循的教程/指南的链接:http://xboxforums.create.msdn.com/forums/p/109484/647991.aspx

我不确定如何传入getpath段的起始值和结束值,这些值是世界空间或对象空间中的值还是什么?如果我执行vector3值并输入它们作为开始值和结束值(然后随后将它们设置在数组上的某个位置),我没有得到显示路径查找的值数组,我只是在navmeshroute中获得这两个逐字值阵列。

这是我尝试运行路径的地方,它在我的更新中。

        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);

            }
        }

0 个答案:

没有答案