If a pawn in the level is using a custom AI Controller that sets the AIPerceptionComponent in code, the editor will crash on PIE after a hot reload.
CrashReporter:
[Link Removed]
1. Open UE4Editor
2. Add Class based on AIController (MyAIController), AISenseConfig (MyAISenseConfig), and AISense (MyAISense)
3. In Visual studio setup files as follows:
a. MyAIController.h
#pragma once #include "AIController.h" #include "Perception/AISense.h" #include "MyAISenseConfig.h" #include "MyAIController.generated.h" UCLASS() class AMyAIController : public AAIController { GENERATED_BODY() AMyAIController(const FObjectInitializer& OI); UMyAISenseConfig* SenseConfig; };
b. MyAIController.cpp
#include "[ProjectName].h" #include "Perception/AIPerceptionComponent.h" #include "MyAIController.h" AMyAIController::AMyAIController(const FObjectInitializer& OI) : Super(OI) { SetPerceptionComponent(*OI.CreateDefaultSubobject<UAIPerceptionComponent>(this, TEXT("PerceptionComponent"))); this->SenseConfig = OI.CreateDefaultSubobject<UMyAISenseConfig>(this, TEXT("MyAISenseConfigs")); GetPerceptionComponent()->ConfigureSense(*this->SenseConfig); }
c. MyAISenseConfig:
#pragma once #include "Perception/AISenseConfig.h" #include "MyAISense.h" #include "MyAISenseConfig.generated.h" UCLASS() class UMyAISenseConfig : public UAISenseConfig { GENERATED_BODY() public: virtual TSubclassOf<UAISense> GetSenseImplementation() const override { return UMyAISense::StaticClass(); } };
4. Compile the code
5. Create blueprint based on Pawn
6. In Blueprint defaults, set AI Controller Class to MyAIController
7. PIE / exit PIE
8. Make a small change to the project code (and/remove a character) and compile to force a hot reload
9. PIE after hot reload
Result:
Editor will crash after the hot reload
MachineId:9FA88CA44B7C623122B0039D6C8BA1B0 EpicAccountId:c807849e05a0413d99e379f2802cae9c Access violation - code c0000005 (first/second chance not available) "" UE4Editor_AIModule!UAIPerceptionSystem::StartPlay() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\aimodule\private\perception\aiperceptionsystem.cpp:500] UE4Editor_Engine!UGameInstance::StartPIEGameInstance() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\engine\private\gameinstance.cpp:273] UE4Editor_UnrealEd!UEditorEngine::CreatePIEGameInstance() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\editor\unrealed\private\playlevel.cpp:3137] UE4Editor_UnrealEd!UEditorEngine::PlayInEditor() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\editor\unrealed\private\playlevel.cpp:2385] UE4Editor_UnrealEd!UEditorEngine::StartQueuedPlayMapRequest() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\editor\unrealed\private\playlevel.cpp:1066] UE4Editor_UnrealEd!UEditorEngine::Tick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\editor\unrealed\private\editorengine.cpp:1244] UE4Editor_UnrealEd!UUnrealEdEngine::Tick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\editor\unrealed\private\unrealedengine.cpp:366] UE4Editor!FEngineLoop::Tick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\launch\private\launchengineloop.cpp:2428] UE4Editor!GuardedMain() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\launch\private\launch.cpp:142] UE4Editor!GuardedMainWrapper() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\launch\private\windows\launchwindows.cpp:126] UE4Editor!WinMain() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\launch\private\windows\launchwindows.cpp:200]
Head over to the existing Questions & Answers thread and let us know what's up.