Skip to main content

Agent Presentation Service

Description

Everything an agent physically does during a conversation goes through IAgentPresentationService: turning to face the listener, presenting a beat group, playing speech and mood animations, disabling cloth, and starting and stopping lip sync.

AgentChatService resolves one on its GameObject when it initializes, and adds DefaultDialoguePresentationService if none is found. See Dialogue Agents.

IAgentPresentationService

NameParametersReturn TypeDescription
LookAtVector3 worldPositionvoidTurns the agent to face a world position.
IsLookingN/AboolTrue while a look-at turn is in progress.
PresentDialogueBeatGroupData beatGroup, DialoguePresentationContext contextfloatPresents every beat in the group and returns the group's content duration.
PlaySpeechAnimationAnimationClip clipvoidPlays a one-shot speech animation.
PlayMoodIdleAnimationClip clipvoidPlays a looping mood idle.
StopDynamicAnimationN/AvoidStops any playing clip, stops lip sync, and restores the animator update mode.
SetClothEnabledbool enabledvoidDisables cloth for the conversation and restores each component's original state.
StartLipSyncAudioSource audioSourcevoidStarts the agent's lip sync provider against the playing clip.
StopLipSyncN/AvoidStops the lip sync provider.

DefaultDialoguePresentationService

The shipped implementation. A MonoBehaviour with two inspector fields.

NameTypeDescription
lookRootTransformTransform rotated by LookAt. Defaults to the component's own transform.
animatorAnimatorAnimator driven during dialogue. Found on the object or its children if unset.

What you can rely on when using it:

  • Dialogue animation keeps playing while the world is paused. You do not need to special-case pausing.
  • Turning to face the listener is a short rotation on the Y axis only, so agents do not tip or lean.
  • SetClothEnabled(true) restores each Cloth component to the state it started in, rather than enabling everything. A cloth component you deliberately left disabled stays disabled.
  • StopDynamicAnimation also stops lip sync, so a cancelled beat does not leave a mouth moving.
  • The lip sync provider is found once, when the agent wakes. Adding one after that has no effect until the agent is re-created. See Lip Sync.

DialoguePresentationContext

The mutable context passed to every beat handler for one beat group. Beat handlers read from it and the presentation pipeline writes to it.

NameTypeDescription
speechTargetGameObjectWhere text beats write their text.
moodTriggerAction<string>Invoked by mood beats with the mood ID.
overheadTextTriggerAction<string>Invoked by text beats so overhead text can mirror the line.
presentationServiceIAgentPresentationServiceThe presenting service. Filled in automatically if null.
nodeIdstringNode the beat group belongs to. Part of the localisation key.
beatGroupIndexintIndex within the node. Part of the localisation key.
speakerIAgentServiceThe speaking agent.
listenerIAgentServiceThe listening agent.
resolvedTextstringLocalised text, resolved before handlers run. Prefer this over the beat's field.
resolvedAudioClipAudioClipLocalised clip, resolved before handlers run.
activeMoodIdstringMood in effect, used as a camera hint.
audioDurationfloatDuration of the resolved clip.

Localised content is resolved once per beat group, keyed as {nodeId}#{beatGroupIndex}, and only for beats whose registration declares the matching LocalisationCapability. Custom beat handlers should read resolvedText and resolvedAudioClip when they are non-null and fall back to the beat's own fields otherwise. See Localisation and Beat Extensibility.