> For the complete documentation index, see [llms.txt](https://docs.convai.com/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.convai.com/api-docs/plugins-and-integrations/convai-unity-sdk/features/conversation-targeting/script-the-conversation-target.md).

# Script the conversation target

Move the conversation to a specific character from a script, and choose which character a room opens on when it connects.

Move the conversation to a specific character from a script with `ConvaiManager.TalkTo`, or choose which character a room opens on with `ConvaiManager.SetInitialCharacter`. Use this page when a dialogue menu, a quest step, or a trigger volume needs to decide who the player is addressing, rather than the player's view or position.

### Prerequisites

* Two or more `ConvaiCharacter` components registered in the scene
* A reference to the active `ConvaiManager`

### Point the conversation at a character

`TalkTo` is the verb for a scripted conversation change. Call it at any time — it does nothing when the room is not a multi-character room or the character is not in it.

```csharp
ConvaiManager manager = ConvaiManager.ActiveManager;
manager.TalkTo(questGiver);
```

`TalkTo` works under any targeting mode, including `LookAt` and `Proximity` — it does not require `Manual`. Under an automatic mode, the next evaluation can move the conversation again once the player looks elsewhere or moves. Choose `Manual` when nothing but scripted calls should ever move the target.

{% hint style="info" %}
If the player is mid-sentence when `TalkTo` is called, the request is held until that utterance ends, so a call made while the player is speaking does not split their sentence across two characters.
{% endhint %}

### Choose which character a room opens on

`SetInitialCharacter` chooses which character speaks first when the room connects — a different job from `TalkTo`. It is setup, not steering: it decides where a conversation starts, and calling it on an already-connected room queues a reconnect rather than moving the current conversation. Leaving it unset is normal — the first character in scene order takes the first turn.

```csharp
manager.SetInitialCharacter(receptionist);
```

{% hint style="warning" %}
`SetInitialCharacter` only decides who takes the first turn. Under `LookAt` and `Proximity`, the conversation is re-evaluated from the moment the room is ready and moves off this character as soon as another one scores better. To move the conversation in a live room, call `TalkTo`, not `SetInitialCharacter`.
{% endhint %}

### Read the current target

```csharp
ConvaiCharacter target = manager.ConversationTarget;
ConversationTargetSwitchVerdict why = manager.ConversationTargetingStatus;
```

`ConversationTargetingStatus` names the reason the last targeting decision went the way it did — useful for telling a held target apart from a stuck one, since from the outside they look identical.

### Subscribe to targeting events

```csharp
manager.ConversationTargetRequested += character => ShowHint(character);
manager.ConversationTargetChanged   += character => Confirm(character);
```

`ConversationTargetRequested` fires after the SDK closes player input and immediately before it attempts to send the target change; the send can still fail. `ConversationTargetChanged` fires when an authoritative response from Convai reconciles the route — a round trip later. Anything Convai does as a consequence of the move, including ending the previous character's turn, happens between the two events.

### One character speaks at a time

Calling `TalkTo` ends the previous character's turn immediately, even mid-sentence — see [One character speaks at a time](/api-docs/plugins-and-integrations/convai-unity-sdk/features/conversation-targeting/how-conversation-targeting-works.md#one-character-speaks-at-a-time) for the full rule and how to avoid cutting off a scripted line.

### Verify the change

Call `TalkTo` in Play mode and confirm the conversation moves to the specified character — the character's audio and lip sync should start on the next response, and `ConversationTarget` should return that character.

### Next steps

{% content-ref url="/pages/keSCXjT3Q7LiyrD28XuS" %}
[Write a custom targeting rule](/api-docs/plugins-and-integrations/convai-unity-sdk/features/conversation-targeting/custom-targeting-rule.md)
{% endcontent-ref %}

{% content-ref url="/pages/O4HC64QMEI0DrwmGFprK" %}
[Conversation targeting reference](/api-docs/plugins-and-integrations/convai-unity-sdk/features/conversation-targeting/targeting-reference.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.convai.com/api-docs/plugins-and-integrations/convai-unity-sdk/features/conversation-targeting/script-the-conversation-target.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
