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) <noreply@anthropic.com>
This commit is contained in:
2026-04-17 14:38:25 +02:00
parent 13da8293c1
commit cd43ae6adc
3 changed files with 9 additions and 0 deletions

View File

@@ -243,8 +243,10 @@ void APS_Editor_PlayerController::StartSimulation()
{ {
if (APawn* P = Cast<APawn>(Weak.Get())) if (APawn* P = Cast<APawn>(Weak.Get()))
{ {
P->SetActorTickEnabled(true);
if (AAIController* AIC = Cast<AAIController>(P->GetController())) if (AAIController* AIC = Cast<AAIController>(P->GetController()))
{ {
AIC->SetActorTickEnabled(true);
if (UBrainComponent* Brain = AIC->GetBrainComponent()) if (UBrainComponent* Brain = AIC->GetBrainComponent())
{ {
Brain->RestartLogic(); Brain->RestartLogic();
@@ -269,8 +271,10 @@ void APS_Editor_PlayerController::StopSimulation()
{ {
if (APawn* P = Cast<APawn>(Weak.Get())) if (APawn* P = Cast<APawn>(Weak.Get()))
{ {
P->SetActorTickEnabled(false);
if (AAIController* AIC = Cast<AAIController>(P->GetController())) if (AAIController* AIC = Cast<AAIController>(P->GetController()))
{ {
AIC->SetActorTickEnabled(false);
if (UBrainComponent* Brain = AIC->GetBrainComponent()) if (UBrainComponent* Brain = AIC->GetBrainComponent())
{ {
Brain->StopLogic(TEXT("PS_Editor")); Brain->StopLogic(TEXT("PS_Editor"));

View File

@@ -268,10 +268,12 @@ bool UPS_Editor_SceneSerializer::LoadScene(const FString& SceneName, UPS_Editor_
{ {
if (AAIController* AIC = Cast<AAIController>(Pawn->GetController())) if (AAIController* AIC = Cast<AAIController>(Pawn->GetController()))
{ {
AIC->SetActorTickEnabled(false);
if (UBrainComponent* Brain = AIC->GetBrainComponent()) if (UBrainComponent* Brain = AIC->GetBrainComponent())
{ {
Brain->StopLogic(TEXT("PS_Editor")); Brain->StopLogic(TEXT("PS_Editor"));
} }
Pawn->SetActorTickEnabled(false);
} }
} }
}); });

View File

@@ -187,10 +187,13 @@ AActor* UPS_Editor_SpawnManager::SpawnFromCatalogAtLocation(int32 Index, FVector
{ {
if (AAIController* AIC = Cast<AAIController>(P->GetController())) if (AAIController* AIC = Cast<AAIController>(P->GetController()))
{ {
AIC->SetActorTickEnabled(false);
if (UBrainComponent* Brain = AIC->GetBrainComponent()) if (UBrainComponent* Brain = AIC->GetBrainComponent())
{ {
Brain->StopLogic(TEXT("PS_Editor")); Brain->StopLogic(TEXT("PS_Editor"));
} }
// Disable AI perception
P->SetActorTickEnabled(false);
} }
} }
}); });