x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Implementing Custom Pathfinding: Bugs and Crashes

Hello there, for my project, I wanted to implement a custom Pathfinding that works without a nav mesh. The idea was, that I was making a solar system with space ships navigating in 3D. It is an RTS, the idea was to implement an algorithm, that draws a direct path from A to B and using avoidance in his close proximity for anything on it's way (maybe even through detour, haven't tested it yet). I thought this might be a good idea, as nearly anything will be somehow moving (even the planets), therefore I won't have static obstacles, and the ships can directly fly around everything (they can't get stuck in holes or similar). I have some coding experiene, but not much and am fairly new to c++.

Now to my actual problem: I was already able to implement my own pathfinding system through extending the ANavigationData class. I was basically following this tutorial, with the exeption of extending ANavigationData instead of ARecastNavMesh (as I don't want nav mesh, as explained). Have a look at the link under "Hooking Our RecastNavMesh Into The Engine" if you want to see how I hooked it up with my project. So far, my code works and I have no compiler errors, the path is simply one between the pawn position and a goal position. But I have to fight with some odd behaviour.

  1. My custom pathfinding class (called AShipNavigation) does only do things (printing out logs) when I add a Nav Mesh Bounds Volume to the scene. The pawn does still not move, and when I try to observe it with the visual logger, the engine simply crashes. In the Log, I cannot find any messages or that the engine writes that it is terminating by purpose. Have a look at the Crash Log, the Warnings at the buttom are Logs written by me (proving that my own NavigationData class is hooked up and runs). When running it through the VS Windows Debugger, I get an exception that my NavMesh was nullptr.

  2. When running the map without the nav mesh bounds volume, nothing happens. My pathfinder doesn't fire, the move functions return failure instead success. Observing it with the visual logger, I receive the message: "LogAINavigation (Warning) Unable to find NavigationData instance while calling AAIController::BuildPathfindingQuery"

My conclusion: When adding the nav mesh bounds, somehow an (invisible?) NavigationData instance is generated. When adding the nav mesh bounds, one is generated for recast nav mesh, which doesn't match my pathfinding. In the tutorial it works of cause, as the A* pathfinding is derived from the recast nav mesh. When I therefore want to run my pathfinding, I have to add something, probably the NavigationData instance the visual logger is missing in case 2. But how? And where?

In general, this whole thing is a big pain in the ass, as there are a lot of classes, like Navigation System oder NavigationData, that are nowhere explained, not even the code has a comment at the start of each headerfile to explain what the classes' purpose is. This is a bit tiring.. the documentation is basicly just a collection of all functions, doesn't tell more then the code already does.

Thanks if you read so far, I hope someone knows the navigation system better then me and knows what I am missing.

Product Version: UE 4.21
Tags:
gernsback.log (59.5 kB)
more ▼

asked Apr 15 '19 at 02:01 PM in C++ Programming

avatar image

Dividuum
10 2 3 7

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Ok, here is the solution, in case anyone comes across this very same issue:

  1. I had to activate my own ShipNavigation Navigation Data as the "Preferred Nav Data" in the pawns movement component.

  2. I created a scene manager class that is in every one of my scenes. Over there. I implemented the following code into the beginPlay method:

.h:


    UNavigationSystemV1* CurrentNavSys;
    AShipNavigation* ShipNavigationInstance;
    const FNavDataConfig* NavigationDataConfig;

.cpp:

 CurrentNavSys = FNavigationSystem::GetCurrent<UNavigationSystemV1>(GetWorld());
 check(CurrentNavSys);
 NavigationDataConfig = &CurrentNavSys->GetDefaultSupportedAgent();

 if (CurrentNavSys)
 {
     if (!ShipNavigationInstance)
     {
         ShipNavigationInstance = AShipNavigation::SpawnInstance(CurrentNavSys, NavigationDataConfig);
     }
     else
     {
         UE_VLOG(this, LogNavigation, Warning, TEXT("ASolarSystemManager::ASolarSystemManager ShipNavigationInstance already set"));
     }
 }
 else
 {
     UE_VLOG(this, LogNavigation, Warning, TEXT("ASolarSystemManager::ASolarSystemManager couldn't find a Navigation System"));
 }

Important note: check the code yourself, I am currently getting crashes sometimes when using the visual logger, but the code compiles without errors.

Basicly, I am creating and the level begin my custom navigation data as an instance.

more ▼

answered Apr 23 '19 at 09:16 AM

avatar image

Dividuum
10 2 3 7

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question