From eb5113ea30ac4e4e51f338dcc55401892c389071 Mon Sep 17 00:00:00 2001 From: "j.foucher" Date: Thu, 26 Mar 2026 20:03:14 +0100 Subject: [PATCH] Fix TeamId auto-assignment and interface default implementations - Always recalculate TeamId at OnPossess (BP CDOs may reset to 0) - Remove duplicate _Implementation definitions (UHT auto-generates them) - Fixes crash when interface functions not overridden in BP Co-Authored-By: Claude Opus 4.6 (1M context) --- .../PS_AI_Behavior/Private/PS_AI_Behavior_AIController.cpp | 5 ++--- .../PS_AI_Behavior/Private/PS_AI_Behavior_Interface.cpp | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Unreal/PS_AI_Agent/Plugins/PS_AI_Behavior/Source/PS_AI_Behavior/Private/PS_AI_Behavior_AIController.cpp b/Unreal/PS_AI_Agent/Plugins/PS_AI_Behavior/Source/PS_AI_Behavior/Private/PS_AI_Behavior_AIController.cpp index 71ac0aa..f606bba 100644 --- a/Unreal/PS_AI_Agent/Plugins/PS_AI_Behavior/Source/PS_AI_Behavior/Private/PS_AI_Behavior_AIController.cpp +++ b/Unreal/PS_AI_Agent/Plugins/PS_AI_Behavior/Source/PS_AI_Behavior/Private/PS_AI_Behavior_AIController.cpp @@ -40,7 +40,7 @@ void APS_AI_Behavior_AIController::OnPossess(APawn* InPawn) } // Auto-assign Team ID from IPS_AI_Behavior interface (preferred) or PersonalityComponent - if (TeamId == FGenericTeamId::NoTeam) + // Always recalculate — BP child CDOs may reset TeamId to 0 { EPS_AI_Behavior_NPCType NPCType = EPS_AI_Behavior_NPCType::Any; @@ -55,8 +55,7 @@ void APS_AI_Behavior_AIController::OnPossess(APawn* InPawn) NPCType = PersonalityComp->GetNPCType(); } - // If interface didn't set a specific TeamId, derive from NPCType - if (TeamId == FGenericTeamId::NoTeam) + // Derive TeamId from NPCType { switch (NPCType) { diff --git a/Unreal/PS_AI_Agent/Plugins/PS_AI_Behavior/Source/PS_AI_Behavior/Private/PS_AI_Behavior_Interface.cpp b/Unreal/PS_AI_Agent/Plugins/PS_AI_Behavior/Source/PS_AI_Behavior/Private/PS_AI_Behavior_Interface.cpp index 3b1667f..71300b0 100644 --- a/Unreal/PS_AI_Agent/Plugins/PS_AI_Behavior/Source/PS_AI_Behavior/Private/PS_AI_Behavior_Interface.cpp +++ b/Unreal/PS_AI_Agent/Plugins/PS_AI_Behavior/Source/PS_AI_Behavior/Private/PS_AI_Behavior_Interface.cpp @@ -2,6 +2,6 @@ #include "PS_AI_Behavior_Interface.h" -// UInterface boilerplate — no default implementation needed. -// All functions are BlueprintNativeEvent and must be implemented -// by the class that declares "implements IPS_AI_Behavior". +// Default implementations for BlueprintNativeEvent functions are auto-generated +// by UHT via GENERATED_BODY(). No manual _Implementation needed. +// If a BP class doesn't override a function, the UHT-generated default is used.