From cd43ae6adc136599b4fcf3d2a31a815d1119353a Mon Sep 17 00:00:00 2001 From: "j.foucher" Date: Fri, 17 Apr 2026 14:38:25 +0200 Subject: [PATCH] Fully disable AI in editor mode via SetActorTickEnabled - Disable tick on both Pawn and AIController when not simulating - Stops BT, perception, gaze, and all per-frame logic - Simulate mode re-enables tick + RestartLogic on all spawned pawns Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Source/PS_Editor/GameMode/PS_Editor_PlayerController.cpp | 4 ++++ .../PS_Editor/Serialization/PS_Editor_SceneSerializer.cpp | 2 ++ .../Source/PS_Editor/Spawn/PS_Editor_SpawnManager.cpp | 3 +++ 3 files changed, 9 insertions(+) diff --git a/Unreal/Plugins/PS_Editor/Source/PS_Editor/GameMode/PS_Editor_PlayerController.cpp b/Unreal/Plugins/PS_Editor/Source/PS_Editor/GameMode/PS_Editor_PlayerController.cpp index af54a82..aaa7e82 100644 --- a/Unreal/Plugins/PS_Editor/Source/PS_Editor/GameMode/PS_Editor_PlayerController.cpp +++ b/Unreal/Plugins/PS_Editor/Source/PS_Editor/GameMode/PS_Editor_PlayerController.cpp @@ -243,8 +243,10 @@ void APS_Editor_PlayerController::StartSimulation() { if (APawn* P = Cast(Weak.Get())) { + P->SetActorTickEnabled(true); if (AAIController* AIC = Cast(P->GetController())) { + AIC->SetActorTickEnabled(true); if (UBrainComponent* Brain = AIC->GetBrainComponent()) { Brain->RestartLogic(); @@ -269,8 +271,10 @@ void APS_Editor_PlayerController::StopSimulation() { if (APawn* P = Cast(Weak.Get())) { + P->SetActorTickEnabled(false); if (AAIController* AIC = Cast(P->GetController())) { + AIC->SetActorTickEnabled(false); if (UBrainComponent* Brain = AIC->GetBrainComponent()) { Brain->StopLogic(TEXT("PS_Editor")); diff --git a/Unreal/Plugins/PS_Editor/Source/PS_Editor/Serialization/PS_Editor_SceneSerializer.cpp b/Unreal/Plugins/PS_Editor/Source/PS_Editor/Serialization/PS_Editor_SceneSerializer.cpp index 32abe47..b3c4721 100644 --- a/Unreal/Plugins/PS_Editor/Source/PS_Editor/Serialization/PS_Editor_SceneSerializer.cpp +++ b/Unreal/Plugins/PS_Editor/Source/PS_Editor/Serialization/PS_Editor_SceneSerializer.cpp @@ -268,10 +268,12 @@ bool UPS_Editor_SceneSerializer::LoadScene(const FString& SceneName, UPS_Editor_ { if (AAIController* AIC = Cast(Pawn->GetController())) { + AIC->SetActorTickEnabled(false); if (UBrainComponent* Brain = AIC->GetBrainComponent()) { Brain->StopLogic(TEXT("PS_Editor")); } + Pawn->SetActorTickEnabled(false); } } }); diff --git a/Unreal/Plugins/PS_Editor/Source/PS_Editor/Spawn/PS_Editor_SpawnManager.cpp b/Unreal/Plugins/PS_Editor/Source/PS_Editor/Spawn/PS_Editor_SpawnManager.cpp index 78aceb9..7427df8 100644 --- a/Unreal/Plugins/PS_Editor/Source/PS_Editor/Spawn/PS_Editor_SpawnManager.cpp +++ b/Unreal/Plugins/PS_Editor/Source/PS_Editor/Spawn/PS_Editor_SpawnManager.cpp @@ -187,10 +187,13 @@ AActor* UPS_Editor_SpawnManager::SpawnFromCatalogAtLocation(int32 Index, FVector { if (AAIController* AIC = Cast(P->GetController())) { + AIC->SetActorTickEnabled(false); if (UBrainComponent* Brain = AIC->GetBrainComponent()) { Brain->StopLogic(TEXT("PS_Editor")); } + // Disable AI perception + P->SetActorTickEnabled(false); } } });