Add uncrouch on state change and flee: civilians stand up when leaving cover
- AIController: auto uncrouch when leaving Fleeing/TakingCover state - FleeFrom: uncrouch at start of flee (civilian was still crouched from HidingSpot) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
391a35ac2c
commit
011bfcf62a
@ -2,6 +2,7 @@
|
||||
|
||||
#include "BT/PS_AI_Behavior_BTTask_FleeFrom.h"
|
||||
#include "PS_AI_Behavior_AIController.h"
|
||||
#include "PS_AI_Behavior_Interface.h"
|
||||
#include "PS_AI_Behavior_Definitions.h"
|
||||
#include "BehaviorTree/BlackboardComponent.h"
|
||||
#include "NavigationSystem.h"
|
||||
@ -20,6 +21,13 @@ EBTNodeResult::Type UPS_AI_Behavior_BTTask_FleeFrom::ExecuteTask(
|
||||
APS_AI_Behavior_AIController* AIC = Cast<APS_AI_Behavior_AIController>(OwnerComp.GetAIOwner());
|
||||
if (!AIC || !AIC->GetPawn()) return EBTNodeResult::Failed;
|
||||
|
||||
// Stand up if crouching (e.g. was hiding at a cover point before fleeing)
|
||||
APawn* FleePawn = AIC->GetPawn();
|
||||
if (FleePawn->Implements<UPS_AI_Behavior_Interface>())
|
||||
{
|
||||
IPS_AI_Behavior_Interface::Execute_SetBehaviorCrouch(FleePawn, false);
|
||||
}
|
||||
|
||||
UBlackboardComponent* BB = OwnerComp.GetBlackboardComponent();
|
||||
if (!BB) return EBTNodeResult::Failed;
|
||||
|
||||
|
||||
@ -237,6 +237,18 @@ void APS_AI_Behavior_AIController::SetBehaviorState(EPS_AI_Behavior_State NewSta
|
||||
}
|
||||
Blackboard->SetValueAsEnum(PS_AI_Behavior_BB::State, NewVal);
|
||||
|
||||
// ─── Leaving cover/hiding: stand up ─────────────────────────
|
||||
const EPS_AI_Behavior_State OldState = static_cast<EPS_AI_Behavior_State>(OldVal);
|
||||
if ((OldState == EPS_AI_Behavior_State::Fleeing || OldState == EPS_AI_Behavior_State::TakingCover)
|
||||
&& NewState != EPS_AI_Behavior_State::Fleeing && NewState != EPS_AI_Behavior_State::TakingCover)
|
||||
{
|
||||
APawn* MyPawn = GetPawn();
|
||||
if (MyPawn && MyPawn->Implements<UPS_AI_Behavior_Interface>())
|
||||
{
|
||||
IPS_AI_Behavior_Interface::Execute_SetBehaviorCrouch(MyPawn, false);
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Dead: shut down all AI systems ─────────────────────────
|
||||
if (NewState == EPS_AI_Behavior_State::Dead)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user