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
| Name | Parameters | Return Type | Description |
|---|---|---|---|
| LookAt | Vector3 worldPosition | void | Turns the agent to face a world position. |
| IsLooking | N/A | bool | True while a look-at turn is in progress. |
| Present | DialogueBeatGroupData beatGroup, DialoguePresentationContext context | float | Presents every beat in the group and returns the group's content duration. |
| PlaySpeechAnimation | AnimationClip clip | void | Plays a one-shot speech animation. |
| PlayMoodIdle | AnimationClip clip | void | Plays a looping mood idle. |
| StopDynamicAnimation | N/A | void | Stops any playing clip, stops lip sync, and restores the animator update mode. |
| SetClothEnabled | bool enabled | void | Disables cloth for the conversation and restores each component's original state. |
| StartLipSync | AudioSource audioSource | void | Starts the agent's lip sync provider against the playing clip. |
| StopLipSync | N/A | void | Stops the lip sync provider. |
DefaultDialoguePresentationService
The shipped implementation. A MonoBehaviour with two inspector fields.
| Name | Type | Description |
|---|---|---|
| lookRoot | Transform | Transform rotated by LookAt. Defaults to the component's own transform. |
| animator | Animator | Animator 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 eachClothcomponent to the state it started in, rather than enabling everything. A cloth component you deliberately left disabled stays disabled.StopDynamicAnimationalso 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.
| Name | Type | Description |
|---|---|---|
| speechTarget | GameObject | Where text beats write their text. |
| moodTrigger | Action<string> | Invoked by mood beats with the mood ID. |
| overheadTextTrigger | Action<string> | Invoked by text beats so overhead text can mirror the line. |
| presentationService | IAgentPresentationService | The presenting service. Filled in automatically if null. |
| nodeId | string | Node the beat group belongs to. Part of the localisation key. |
| beatGroupIndex | int | Index within the node. Part of the localisation key. |
| speaker | IAgentService | The speaking agent. |
| listener | IAgentService | The listening agent. |
| resolvedText | string | Localised text, resolved before handlers run. Prefer this over the beat's field. |
| resolvedAudioClip | AudioClip | Localised clip, resolved before handlers run. |
| activeMoodId | string | Mood in effect, used as a camera hint. |
| audioDuration | float | Duration 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.