Fix head/eye tracking lost on 2nd conversation cycle (persistent session)
Three issues prevented posture re-activation on re-entry: - StartConversation skipped bNetIsConversing/NetConversatingPawn in standalone (guarded by NM_Standalone check) so ApplyConversationPosture always deactivated - SetSelectedAgent required !IsConnected() to auto-start conversation, but in persistent mode the WS stays connected → StartConversation never called on re-entry - AttachPostureTarget never set Posture->bActive = true, relying solely on ApplyConversationPosture which could be skipped due to the above condition Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d035f5410a
commit
ac2d40b67b
@ -260,15 +260,12 @@ void UPS_AI_ConvAgent_ElevenLabsComponent::StartConversation()
|
||||
{
|
||||
if (GetOwnerRole() == ROLE_Authority)
|
||||
{
|
||||
// Server (or standalone): open WebSocket directly.
|
||||
// In networked mode, also set replicated conversation state.
|
||||
if (GetWorld() && GetWorld()->GetNetMode() != NM_Standalone)
|
||||
{
|
||||
APlayerController* PC = GetWorld()->GetFirstPlayerController();
|
||||
// Set conversation state (used by ApplyConversationPosture, posture, LOD, etc.).
|
||||
// In standalone these aren't replicated but are still needed as local state flags.
|
||||
APlayerController* PC = GetWorld() ? GetWorld()->GetFirstPlayerController() : nullptr;
|
||||
bNetIsConversing = true;
|
||||
NetConversatingPlayer = PC;
|
||||
NetConversatingPawn = PC ? PC->GetPawn() : nullptr;
|
||||
}
|
||||
|
||||
// In persistent mode the WebSocket was already opened by the first StartConversation.
|
||||
// Reuse the existing connection — only set up conversation state.
|
||||
|
||||
@ -311,10 +311,13 @@ void UPS_AI_ConvAgent_InteractionComponent::SetSelectedAgent(UPS_AI_ConvAgent_El
|
||||
NewAgent->GetOwner() ? *NewAgent->GetOwner()->GetName() : TEXT("(null)"));
|
||||
}
|
||||
|
||||
// Network: auto-start conversation if the agent isn't connected yet.
|
||||
// Network: auto-start conversation if no active conversation.
|
||||
// In persistent session mode, the WebSocket stays connected but
|
||||
// bNetIsConversing is false between interactions — we still need
|
||||
// to call StartConversation() to re-activate posture and mic.
|
||||
// Only when bAutoStartConversation is true — otherwise the user must
|
||||
// call StartConversationWithSelectedAgent() explicitly (e.g. on key press).
|
||||
if (bAutoStartConversation && !NewAgent->IsConnected() && !NewAgent->bNetIsConversing)
|
||||
if (bAutoStartConversation && !NewAgent->bNetIsConversing)
|
||||
{
|
||||
// On the server, call StartConversation() directly.
|
||||
// On clients, route through our relay RPC (clients can't call
|
||||
@ -494,6 +497,7 @@ void UPS_AI_ConvAgent_InteractionComponent::AttachPostureTarget(
|
||||
if (UPS_AI_ConvAgent_PostureComponent* Posture = FindPostureOnAgent(AgentPtr))
|
||||
{
|
||||
Posture->TargetActor = GetOwner();
|
||||
Posture->bActive = true;
|
||||
|
||||
// Reset the body target to the actor's current facing so body tracking
|
||||
// starts fresh on re-entry. Without this, TargetBodyWorldYaw retains
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user