bug fix pour 5.7

This commit is contained in:
2026-05-06 17:52:08 +02:00
parent a1e34e6dfa
commit ceaf89f836

View File

@@ -263,7 +263,7 @@ AActor* UPS_AI_Behavior_PerceptionComponent::GetHighestThreatActor()
{ {
// Owner is the AIController, get the Pawn // Owner is the AIController, get the Pawn
const AAIController* AIC = Cast<AAIController>(Owner); const AAIController* AIC = Cast<AAIController>(Owner);
const APawn* MyPawn = AIC ? AIC->GetPawn() : Cast<APawn>(const_cast<AActor*>(Owner)); const APawn* MyPawn = AIC ? ToRawPtr(AIC->GetPawn()) : Cast<APawn>(const_cast<AActor*>(Owner));
if (MyPawn) if (MyPawn)
{ {
@@ -369,7 +369,7 @@ AActor* UPS_AI_Behavior_PerceptionComponent::GetHighestThreatActor(
// Get our Pawn for IsTargetActorValid checks // Get our Pawn for IsTargetActorValid checks
const AAIController* AIC = Cast<AAIController>(Owner); const AAIController* AIC = Cast<AAIController>(Owner);
APawn* MyPawn = AIC ? AIC->GetPawn() : Cast<APawn>(const_cast<AActor*>(Owner)); APawn* MyPawn = AIC ? ToRawPtr(AIC->GetPawn()) : Cast<APawn>(const_cast<AActor*>(Owner));
// ─── Score accumulation per resolved actor ─────────────────────── // ─── Score accumulation per resolved actor ───────────────────────
// Multiple RawActors can resolve to the same Pawn (e.g. Pawn seen + weapon heard). // Multiple RawActors can resolve to the same Pawn (e.g. Pawn seen + weapon heard).
@@ -611,7 +611,7 @@ float UPS_AI_Behavior_PerceptionComponent::CalculateThreatLevel()
// Get our AIController and Pawn for checks // Get our AIController and Pawn for checks
const AAIController* AIC = Cast<AAIController>(Owner); const AAIController* AIC = Cast<AAIController>(Owner);
APawn* MyPawn = AIC ? AIC->GetPawn() : Cast<APawn>(const_cast<AActor*>(Owner)); APawn* MyPawn = AIC ? ToRawPtr(AIC->GetPawn()) : Cast<APawn>(const_cast<AActor*>(Owner));
for (AActor* RawActor : PerceivedActors) for (AActor* RawActor : PerceivedActors)
{ {