I also want to override the RecastNavMesh. So I have tested the method of “Custom Recastnavmesh. FindPath method”. My project name is TestAI, and I’ve also modified the DefaultEngine.ini file.There are two such files in my project. One is .\TestAI\Config\DefaultEngine.ini, the other is .\TestAI\Saved\StagedBuilds\WindowsNoEditor\TestAI\Config\DefaultEngine.ini. I modified two
DefaultEngine.ini:
…
- [/Script/Engine.NavigationSystem]
- RequiredNavigationDataClassNames=/Script/TestAI.MyRecastNavMesh
And I add MyRecastNavMesh class through ue editor. To test my program, the MyRecastNavMesh.h and MyRecastNavMesh.cpp have nothing but default code.
The header file MyRecastNavMesh.h:
- UCLASS() class TOPDOWNCPP_API
- AMyRecastNavMesh : public ARecastNavMesh {
-
GENERATED_BODY()
- }
Now, I overrided my aicontroller and using bellow codes:
-
UNavigationSystem* const NavSys = GetWorld()->GetNavigationSystem();
-
const ANavigationData* NavData = NavSys->GetNavDataForProps(*AgentProperties);
const ARecastNavMesh* NavMesh = Cast<ARecastNavMesh > (NavData);
Such three codes have been verified before. And now I use AMyRecastNavMesh instead of ARecastNavMesh.
3. `const AMyRecastNavMesh* NavMesh = Cast< AMyRecastNavMesh> (NavData);`
the program compiled successfully. but we debug the progrm , NavMesh is 0x00000000 and the program crashed.
What is wrong?
Thanks.