Andy90 Posted February 6 Share Posted February 6 Hey, i have another bug. Right now the nav mesh works fine when the player starts with postion 0,0,0. But when i move the player to another postion it wont work anymore. https://streamable.com/x7r6id You can check it within my project from the old bug report. Just move the player to another position and start the game. 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted February 7 Share Posted February 7 Thank you for reporting this. I am investigating... Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted February 7 Share Posted February 7 There are five maps in your project. Which one should I be testing? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Andy90 Posted February 7 Author Share Posted February 7 I think test2 fits the best. 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted February 7 Share Posted February 7 I am getting a strange result. If I move the player start position in the editor, he always starts back at the zero position. test2_poschanged.zip Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted February 7 Share Posted February 7 This is why: /// <summary> /// Setup the Controller /// </summary> void MouseMovementController::Start() { auto entity = GetEntity(); entity->AddTag("player"); /// ToDo remove when nav mesh bug is fixed entity->SetPosition(0, 0, 0); entity->SetRotation(0, 180, 0); /// With the SetPosition command commented out, I can now produce the error... Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Andy90 Posted February 7 Author Share Posted February 7 yeah i changed this. Forgot about it Quote Link to comment Share on other sites More sharing options...
Josh Posted February 8 Share Posted February 8 The behavior is definitely doing something strange. I am going to try getting rid of the player and just creating a simple nav agent in the main code file... Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Solution Josh Posted February 8 Solution Share Posted February 8 This is what you need at the bottom of MouseMovementController::Start: ///Create a new NavAgent for the player character this->agent = CreateNavAgent(this->nav_mesh); this->agent->SetPosition(entity->GetPosition(true)); entity->SetPosition(0, 0, 0); entity->SetRotation(0, 0, 0); entity->Attach(agent); The player's position and rotation are retained as the local offset and rotation when it is attached to the navagent. This allows you to set an offset, or reverse the orientation of the player. However, as we have seen, this can be confusing and cause unintended consequences, so maybe the command should include an optional offset position and rotation instead. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Andy90 Posted February 8 Author Share Posted February 8 Its working. Thanks. Maybe an example within the documentation would be nice. So other ppl wont have this issue. This is the current code from Ultra Engine - Best game engine for VR optimized for fastest virtual reality 3D performance #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create a framebuffer auto framebuffer = CreateFramebuffer(window); //Create a world auto world = CreateWorld(); //Create a camera auto camera = CreateCamera(world); camera->SetFov(70); camera->SetClearColor(0.125); camera->SetPosition(0, 3, -6); camera->SetRotation(35,0,0); //Create light auto light = CreateBoxLight(world); light->SetRange(-20, 20); light->SetArea(20, 20); light->SetRotation(35, 35, 0); light->SetColor(3); //Create scene auto ground = CreateBox(world, 10, 1, 10); ground->SetPosition(0, -0.5, 0); ground->SetColor(0, 1, 0); auto wall = CreateBox(world, 1, 2, 4); //Create navmesh auto navmesh = CreateNavMesh(world, 10, 5, 10, 4, 4); navmesh->Build(); //Create player auto player = CreateCylinder(world, 0.4, 1.8); player->SetNavObstacle(false); player->SetColor(0, 0, 1); auto agent = CreateNavAgent(navmesh); player->Attach(agent); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->MouseHit(MOUSE_LEFT)) { auto mousepos = window->GetMousePosition(); auto rayinfo = camera->Pick(framebuffer, mousepos.x, mousepos.y); if (rayinfo.success) { agent->Navigate(rayinfo.position); } } world->Update(); world->Render(framebuffer); } return 0; } 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.