Skip to main content

Demo: Multiple Characters

1. Opening the Sample Scene

In the Project Panel, click Inworld > Inworld.Samples.RPM > Scenes > SampleMultiCharacters to open the demo scene that supports multiple characters.

SampleMultiChar

Talking to a character.

In the room, there are two characters: Wizard Dotcom and Amy Amish. Once the connection is established, you can speak to them. Use the W A S D buttons on your keyboard to move forward, back, left, and right. You can speak to them directly using your microphone.

TalkTo

Typing or recording to a character.

You can press the ~ button to open or close the text input panel during runtime.

While the panel is open, you can view the history logs for all the characters in the scene and type or record sentences to the current selected character, you can only select a character by the dropdown field.

MultiCharLog

2. Selecting characters

Starting from version 3.1, we offer three different character selection modes.

CharSelectMode

The mode from version 2, which selects characters based on view and sight distance, is back!

We also provide a specified dialogue mode and an automatic dialogue mode. Players can switch between these modes by pressing the Tab key repeatedly.

Sight Selection Mode

This is our default mode. In the Scene view, click on each character to see the character's gizmos. You can drag the Sight Angle and Sight Distance.

Additionally, you can adjust the weights of the player's sight, the character's sight, and the character's sight distance.

These will all determine the character's Priority. Only the character with the highest priority (i.e., the lowest Priority value) will be selected.

SightAngle

In Group Chat Mode, you also need to set the view Threshold for group chats.

SelectingThresh.png

In the current algorithm, this means that only characters with a higher priority (i.e., a lower Priority value) than this threshold will enter the selection pool.

Otherwise, they will only enter the group chat pool.

For example, in the Demo SampleMultiCharacter, the default SelectingThreshold is 0.5, which means that if each character's Priority value is higher than 0.5, they will not be selected and will only exist in the group chat pool. The dialogue mode at this time is broadcast mode.

Specified Selection Mode

You can press the 1 and 2 keys on the keyboard to select the dialogue character, or press 0 to select broadcast mode.

SpecSelect.gif

Auto chat Mode

In this mode, two characters will automatically engage in dialogue until you interrupt.

AutoChat.gif

3. Group Chat

In version 3.4, we introduced the group chat system. At this stage, we only support users to speak to all characters in a Conversation in a broadcast manner.

Although currently only one randomly selected character will respond to you, and you cannot specify a particular character in the Conversation to speak, you can see that characters within the same Conversation recognize each other and remember each other's dialogues.

Convo.gif

Without unlocking Group Chat, we will use the previous logic where you need to approach a character to converse with them.

⚠️ Note: For compatibility with Group Chat, starting from version 3.3, we no longer always designate a CurrentCharacter.

If you are too far from any character in the scene without having Group Chat enabled, no character will respond to you.

In such cases, please approach any character or use the Specific Selecting Method to designate a character for interaction using hotkeys.

EnableGroupChat.png

⚠️ Note:

We will implement the ability to select a target character to speak and a target character to respond in the future.

Once completed, the group chat mode will become the default dialogue system (you won't need to toggle this) and replace the single character mode.

4. About Conversation

Conversation is a new concept we introduced. A Conversation can contain one or more InworldCharacters, and you can speak to any character within a Conversation.

In the Unity SDK Demo, our CharacterHandler3D has and only has ONE Conversation. All new characters joining and leaving will automatically be added to this Conversation.

Players can call StartNewConversation to create multiple Conversations, each encompassing a different number of characters (automatically included by the current CharacterHandler). By managing ConversationID, you can engage in dialogue with multiple Conversations within the same LiveSession.

/// <summary>
/// Start a new conversation.
/// In Unity SDK by default, we only use one single conversation for handling all the characters.
/// But it's able to handle multiple conversations by developers.
///
/// To do so, save those conversation ID and use them correspondingly.
/// </summary>
public virtual void StartNewConversation(string conversationID = null)
=> m_ConversationID = string.IsNullOrEmpty(conversationID) ? Guid.NewGuid().ToString() : conversationID;

public string ConversationID
{
get
{
if (string.IsNullOrEmpty(m_ConversationID))
StartNewConversation();
return m_ConversationID;
}
}

If you're creating your own implementation, you can just set the InworldController.Instance.CurrentCharcter to the character you want, then you can speak or send text to that character.

⚠️ Note: Note: There can be a maximum of 20 active Conversations at the same time. When more than 20 are generated, older Conversations will enter the Evict state until they are reactivated by speaking to them again.