diff --git a/Unreal/PS_AI_Agent/Plugins/PS_AI_ConvAgent/Source/PS_AI_ConvAgent/Private/PS_AI_ConvAgent_InteractionComponent.cpp b/Unreal/PS_AI_Agent/Plugins/PS_AI_ConvAgent/Source/PS_AI_ConvAgent/Private/PS_AI_ConvAgent_InteractionComponent.cpp index 3b5ed4f..b6ae517 100644 --- a/Unreal/PS_AI_Agent/Plugins/PS_AI_ConvAgent/Source/PS_AI_ConvAgent/Private/PS_AI_ConvAgent_InteractionComponent.cpp +++ b/Unreal/PS_AI_Agent/Plugins/PS_AI_ConvAgent/Source/PS_AI_ConvAgent/Private/PS_AI_ConvAgent_InteractionComponent.cpp @@ -66,7 +66,11 @@ void UPS_AI_ConvAgent_InteractionComponent::EndPlay(const EEndPlayReason::Type E // Fire deselection event for cleanup. if (UPS_AI_ConvAgent_ElevenLabsComponent* Agent = SelectedAgent.Get()) { - // Clear posture immediately on shutdown — no delay. + // Stop listening and clear posture immediately on shutdown — no delay. + if (bAutoManageListening) + { + Agent->StopListening(); + } if (bAutoManagePosture) { DetachPostureTarget(Agent); @@ -190,6 +194,12 @@ void UPS_AI_ConvAgent_InteractionComponent::SetSelectedAgent(UPS_AI_ConvAgent_El OldAgent->GetOwner() ? *OldAgent->GetOwner()->GetName() : TEXT("(null)")); } + // ── Listening: stop ────────────────────────────────────────────── + if (bAutoManageListening) + { + OldAgent->StopListening(); + } + // ── Posture: detach ────────────────────────────────────────────── if (bAutoManagePosture && World) { @@ -230,6 +240,12 @@ void UPS_AI_ConvAgent_InteractionComponent::SetSelectedAgent(UPS_AI_ConvAgent_El MicComponent->StartCapture(); } + // ── Listening: start ───────────────────────────────────────────── + if (bAutoManageListening) + { + NewAgent->StartListening(); + } + // ── Posture: attach ────────────────────────────────────────────── if (bAutoManagePosture && World) { diff --git a/Unreal/PS_AI_Agent/Plugins/PS_AI_ConvAgent/Source/PS_AI_ConvAgent/Public/PS_AI_ConvAgent_InteractionComponent.h b/Unreal/PS_AI_Agent/Plugins/PS_AI_ConvAgent/Source/PS_AI_ConvAgent/Public/PS_AI_ConvAgent_InteractionComponent.h index adba675..061e1a3 100644 --- a/Unreal/PS_AI_Agent/Plugins/PS_AI_ConvAgent/Source/PS_AI_ConvAgent/Public/PS_AI_ConvAgent_InteractionComponent.h +++ b/Unreal/PS_AI_Agent/Plugins/PS_AI_ConvAgent/Source/PS_AI_ConvAgent/Public/PS_AI_ConvAgent_InteractionComponent.h @@ -114,6 +114,15 @@ public: ToolTip = "Seconds to wait before the agent stops looking at the pawn.\n0 = immediate.")) float PostureDetachDelay = 0.0f; + // ── Listening management ───────────────────────────────────────────────── + + /** Automatically call StartListening/StopListening on the agent's + * ElevenLabsComponent when selected/deselected. When false, listening + * must be managed from Blueprint. */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PS AI ConvAgent|Interaction|Listening", + meta = (ToolTip = "Automatically open/close the agent's mic turn on selection.\nDisable for manual control (e.g. push-to-talk).")) + bool bAutoManageListening = true; + // ── Debug ──────────────────────────────────────────────────────────────── /** Enable debug logging for this component. */