Skip to main content

CharacterHandler

Module: Inworld.AI. Namespace: Inworld.

This component is part of the InworldController prefab and is responsible for selecting the character with whom the current player is interacting.

Inspector Variables

VariableDescription
Manual Audio HandlingIf checked, developers need to manually call InworldController.Instance.StartAudio() to initiate microphone recording. By default, this option is set to false.

Events

EventDescription
OnCharacterListJoinedTriggered when an InworldCharacter joins the current conversation.
The parameter is the InworldCharacter gameObject.
OnCharacterListLeftTriggered when an InworldCharacter leaves the current conversation.
The parameter is the InworldCharacter gameObject.

Properties

PropertyDescription
IsAnyCharacterSpeakingReturns true if any character is speaking.
CurrentCharacterNamesReturns the brain names of all InworldCharacters in the current conversation.
CurrentCharacterGets or sets the currently interacting character. Note: This is provided for backwards compatibility.
Although you are allowed to talk to multiple characters, sometimes you need to nominate a primary character without unregistering others.

This parameter will overwrite the group chat CurrentCharacters.
CurrentCharactersGets the current interacting characters in the group.
If set, it'll also start audio sampling if ManualAudioHandling is false, and invoke the event OnCharacterChanged.
ManualAudioHandlingIf set to false, the AudioCapture of the InworldController will automatically start recording the player's voice when at least one character is selected. Otherwise, developers need to manually call InworldController.Instance.StartAudio() to initiate the microphone.
SelectingMethodReturns the current Character Selecting Method. If no method is set returns Manual.

API

FunctionDescriptionParameters
ChangeSelectingMethodChange the method of how to select character.
GetCharacterByBrainNameGets the InworldCharacter by any brain name.
May return null if not found.
brainName: target brain Name to send.
GetCharacterByGivenNameGets the first InworldCharacter by the given name.
May return null if not found.
If multiple characters have the same name, it'll return the first one.
brainName: target brain Name to send.
RegisterAdd a InworldCharacter to the character list.
Triggers OnCharacterListJoined
InworldCharacter: target character to add.
UnregisterRemove the character from the character list.
If it's current character, or in the group chat, also remove it.
InworldCharacter: target character to remove.