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:
@@ -243,8 +243,10 @@ void APS_Editor_PlayerController::StartSimulation()
|
||||
{
|
||||
if (APawn* P = Cast<APawn>(Weak.Get()))
|
||||
{
|
||||
P->SetActorTickEnabled(true);
|
||||
if (AAIController* AIC = Cast<AAIController>(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<APawn>(Weak.Get()))
|
||||
{
|
||||
P->SetActorTickEnabled(false);
|
||||
if (AAIController* AIC = Cast<AAIController>(P->GetController()))
|
||||
{
|
||||
AIC->SetActorTickEnabled(false);
|
||||
if (UBrainComponent* Brain = AIC->GetBrainComponent())
|
||||
{
|
||||
Brain->StopLogic(TEXT("PS_Editor"));
|
||||
|
||||
@@ -268,10 +268,12 @@ bool UPS_Editor_SceneSerializer::LoadScene(const FString& SceneName, UPS_Editor_
|
||||
{
|
||||
if (AAIController* AIC = Cast<AAIController>(Pawn->GetController()))
|
||||
{
|
||||
AIC->SetActorTickEnabled(false);
|
||||
if (UBrainComponent* Brain = AIC->GetBrainComponent())
|
||||
{
|
||||
Brain->StopLogic(TEXT("PS_Editor"));
|
||||
}
|
||||
Pawn->SetActorTickEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -187,10 +187,13 @@ AActor* UPS_Editor_SpawnManager::SpawnFromCatalogAtLocation(int32 Index, FVector
|
||||
{
|
||||
if (AAIController* AIC = Cast<AAIController>(P->GetController()))
|
||||
{
|
||||
AIC->SetActorTickEnabled(false);
|
||||
if (UBrainComponent* Brain = AIC->GetBrainComponent())
|
||||
{
|
||||
Brain->StopLogic(TEXT("PS_Editor"));
|
||||
}
|
||||
// Disable AI perception
|
||||
P->SetActorTickEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user