Bug when hot-reloading custom NavArea classes

I experienced the same problem as in this question and further investigated it a bit (with the help of some logging)

By doing that I noticed that when hot reloading a project with a custom NavArea class, it calls FinishDestroy() after calling PostInitProperties() which should register the new implementation.
This will result in the custom NavArea class in not being registered at all and as a consequence rebuilding the nav mesh will show the following error:

"FRecastTileGenerator: Trying to use undefined area class while defining Off-Mesh links! (NavArea_Jump)"

I found only two solutions for now:

  1. Restart the editor after compiling the code each time
  2. Overwrite FinishDestroy() in the custom NavArea class so it skips unregistration

The first one is a massive impact on productivity so I wouldn’t call that a solution.

The second one can be achieved with the following code in for example NavArea_Jump. However it might have unknown side-effects and when removing the custom NavArea class from the code, the editor should definitely be restarted:

void UNavArea_Jump::FinishDestroy()
{
	if (HasAnyFlags(RF_ClassDefaultObject)
#if WITH_HOT_RELOAD
		&& !GIsHotReload
#endif // WITH_HOT_RELOAD
		)
	{
		UE_LOG(LogTemp, Error, TEXT("Did not unregister %s, because of bug in UE4"), *GetClass()->GetName());
		// UNavigationSystem::RequestAreaUnregistering(GetClass());
	}
	UObject::FinishDestroy();
}

Hey olee92-

I created a class based on NavArea and had no issues with compiling / hot reloading the code. Could you explain exactly what the issue is that you were running into and the steps to reproduce it so I can test on my end?

Hi olee92,

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will offer further assistance.

Thank you.

It looks like it’s still happening with 4.14.3 but only once in a while. It’s not happening at every hot reload. I’m having a hard time figuring out why it’s happening, though.

Hey tanis2000-

Can you provide specific information about your case? Are you seeing the same “FRecastTileGenerator” error that olee92 reported? If so, can you provide setup/reproduction steps to help me reproduce the behavior locally?

Yes, the error is exactly the same. The real problem is that this behavior is happening from time to time and I can’t reproduce it systematically. It just happens from time to time after I recompile my C++ code.

You can use this project as a test: GitHub - MieszkoZ/AITutorialCPP: Tutorial ground for showing how UE4 AI should be set up and used.
Just add some brush meshes and nav link proxies to a scene and set those nav link proxies to be NavArea_Jump.

Change a line of code somewhere and recompile from within the editor, run it in simulation, rinse and repeat a couple of times and it should happen to you as well.

I downloaded the project you linked and tried adding Nav Link Proxy, Basic Cubes, and Boxes to the level. and did not see any message about FRecastTileGenerator on hot reload. When you say “set those nav link proxies to NavArea_Jump”, can you explain what you’re referring to? I was able to find Simple Link->AreaClass, Smart Link->EnabledAreaClass & DisabledAreaClass, and Obstacle->ObstacleAreaClass. Each of these can be set to NavAra_Jump. Please elaborate on the exact settings you’re using/changing once you’ve downloaded/opened the project.