Fix IsCoverNeeded decorator: resolve AimTargetActor to owning Pawn
- IsCoverNeeded used Cast<APawn> on ThreatActor which failed for AimTargetActors → always returned true (assume dangerous) → enemies took cover against civilians - Fix: use FindOwningPawn to walk Owner/Instigator chain to the actual Pawn - Revert inline civilian check in EvaluateReaction (decorator handles it in BT) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
011bfcf62a
commit
d6325b373d
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "BT/PS_AI_Behavior_BTDecorator_IsCoverNeeded.h"
|
#include "BT/PS_AI_Behavior_BTDecorator_IsCoverNeeded.h"
|
||||||
#include "PS_AI_Behavior_AIController.h"
|
#include "PS_AI_Behavior_AIController.h"
|
||||||
|
#include "PS_AI_Behavior_PerceptionComponent.h"
|
||||||
#include "PS_AI_Behavior_Interface.h"
|
#include "PS_AI_Behavior_Interface.h"
|
||||||
#include "BehaviorTree/BlackboardComponent.h"
|
#include "BehaviorTree/BlackboardComponent.h"
|
||||||
|
|
||||||
@ -23,11 +24,11 @@ bool UPS_AI_Behavior_BTDecorator_IsCoverNeeded::CalculateRawConditionValue(
|
|||||||
AActor* ThreatActor = Cast<AActor>(BB->GetValueAsObject(PS_AI_Behavior_BB::ThreatActor));
|
AActor* ThreatActor = Cast<AActor>(BB->GetValueAsObject(PS_AI_Behavior_BB::ThreatActor));
|
||||||
if (!ThreatActor) return false;
|
if (!ThreatActor) return false;
|
||||||
|
|
||||||
// If the target doesn't implement the interface, assume dangerous (safe default)
|
// Resolve ThreatActor to owning Pawn (AimTargetActor → Character)
|
||||||
APawn* ThreatPawn = Cast<APawn>(ThreatActor);
|
APawn* ThreatPawn = UPS_AI_Behavior_PerceptionComponent::FindOwningPawn(ThreatActor);
|
||||||
if (!ThreatPawn || !ThreatPawn->Implements<UPS_AI_Behavior_Interface>())
|
if (!ThreatPawn || !ThreatPawn->Implements<UPS_AI_Behavior_Interface>())
|
||||||
{
|
{
|
||||||
return true;
|
return true; // Can't resolve → assume dangerous (safe default)
|
||||||
}
|
}
|
||||||
|
|
||||||
const EPS_AI_Behavior_NPCType TargetType =
|
const EPS_AI_Behavior_NPCType TargetType =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user