示例#1
0
 protected void generateNavigationMeshInstances(App.Navigation nav, Godot.Collections.Array nodes)
 {
     for (int i = 0; i < nodes.Count; i++)
     {
         if (nodes[i] is StaticBody staticBody)
         {
             var meshInstance = staticBody.GetNodeOrNull <MeshInstance>("MeshInstance");
             if (meshInstance != null)
             {
                 NavigationMesh navMesh = new NavigationMesh();
                 navMesh.CreateFromMesh(meshInstance.Mesh);
                 nav.NavmeshAdd(navMesh, meshInstance.GetGlobalTransform());
                 var transform       = meshInstance.Transform;
                 var translation     = meshInstance.Translation;
                 var globalTransform = meshInstance.GlobalTransform;
                 GD.Print("created navmesh for meshinstance");
             }
             else
             {
                 GD.Print("[navmesh] meshinstance skipped (no child named 'MeshInstance')");
             }
         }
         else
         {
             GD.Print("[navmesh] meshinstance skipped (no staticbody)");
         }
     }
 }