Jump to content

Adding NavMesh via editor and in code causes it not to show up in the scene


Go to solution Solved by Josh,

Recommended Posts

Posted

Adding a NavMesh object from the editor and then running the game shows no nav meshes in the scene.

image.thumb.png.20b5db8d998e0a13df09a733d1eea359.png

Calling CreateNavMesh() to add a NavMesh object from code also doesn't show nav meshes in the scene either.

EDIT: Both m_navmeshes and navmeshes members in the `scene` object are 0 (love the m_ prefix, very old school)

Posted

Steps:

- Add NavMesh via editor:

1. Use Object panel to add Navigation Mesh to scene

2. Debug game

Editor_j5fa1gfm91.gif

- Add NavMesh via code:

1. In main.cpp add following code after loading map:

auto navmesh = CreateNavMesh(world, 0, 8, 8);
navmesh->Build();

2. Debug game

Editor_9rsRD61dlI.gif

  • Solution
Posted

It looks like the error is only in the editor, and not in the engine library itself. I updated the editor and this example works:
start.zip

#include "UltraEngine.h"

using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    auto cl = ParseCommandLine(argc, argv);
    
    //Load FreeImage plugin (optional)
    auto fiplugin = LoadPlugin("Plugins/FITextureLoader");

    //Get the displays
    auto displays = GetDisplays();

    //Create a window
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280 * displays[0]->scale, 720 * displays[0]->scale, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);

    //Create a world
    auto world = CreateWorld();

    //Create a framebuffer
    auto framebuffer = CreateFramebuffer(window);

    //Load the map
    WString mapname = "Maps/start.ultra";
    auto scene = LoadMap(world, mapname);

    auto navmesh = scene->navmeshes[0];
    navmesh->SetDebugging(true);

    auto agent = CreateNavAgent(navmesh);
    auto player = CreateBox(world);
    player->SetColor(0, 1, 0);
    player->Attach(agent);

    auto camera = CreateCamera(world);
    camera->SetPosition(0, 1, -4);

    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        if (window->KeyHit(KEY_SPACE)) agent->Navigate(1, 0, 0);

        world->Update();
        world->Render(framebuffer);
    }

    return 0;
}

 

Let's build cool stuff and have fun. :)

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.

×
×
  • Create New...