Skip to main content

InworldController

Module: Inworld.AI. Namespace: Inworld. RequireComponent: InworldClient, AudioCapture, CharacterHandler. Inherited from: SingletonBehavior.

The InworldController acts as the API hub within a Unity application, primarily designed for backward compatibility with previous versions.

It serves as a central point for managing API interfaces, ensuring that the system maintains its interfaces with older versions while delegating the actual execution of each API call to subordinate scripts.

InworldController

Inspector Variables

VariableDescription
Game DataThe current InworldGameData component used to load scenes.
Scene Full NameIf GameData is null, specifying this string will also work for loading scenes.

Properties

PropertyDescription
HasErrorReturns true if any InworldError was received from the Inworld server.
AudioProvides access to the AudioCapture component of the InworldController.
CharacterHandlerProvides access to the CharacterHandler component of the InworldController.
ClientProvides access to the InworldClient component of the InworldController.
StatusRetrieves the current connection status.
CurrentWorkspaceRetrieves the full name of the current workspace.
CurrentSceneRetrieves the full name of the current InworldScene.
CurrentCharacterGets/Sets the current interacting InworldCharacter.
GameDataGets or sets the InworldGameData associated with the InworldController.

API

FunctionDescriptionParameters
LoadDataLoads the InworldGameData and sets client's related data if the game data is not null.gameData: The InworldGameData to load.
InitWithCustomTokenInitializes the SDK using a custom token instead of API key/secret.
This token can be obtained from other applications, such as the InworldWebSDK.
token: The custom token for initialization.
ReconnectReconnects the session or starts a new session if the current session is invalid.
InitInitializes the SDK.
LoadSceneSends a LoadScene request to the Inworld Server.
In ver 3.3 or further, the session must be connected first.
sceneFullName: The full string of the scene to load.
PrepareSessionSent after the ClientStatus is set to Connected.
Sequentially sends Session Config parameters, enabling this session to become interactive.
DisconnectDisconnects from the Inworld Server.
SendTextSends text messages in the current scene.
If there's a current character, it'll be sent to the specific character, otherwise, it'll be sent as broadcast.
text: The message to send.
SendNarrativeActionSends a narrative action in the current scene.
If there's a current character, it'll be sent to the specific character, otherwise, it'll be sent as broadcast.
narrativeAction: The narrative action to send.
CancelResponseCancels response generation for all characters currently generating responses.
Automatically used when sending Text.
For other sending data, such as sending trigger, please consider to use according to your scenario.
SendCancelEventSends the CancelResponse Event to the InworldServer to interrupt the character's speaking.interactionID: The handle of the dialog context that needs to be canceled.
utteracneID: the handle of the current utterance that needs to be cancelled.
SendWorldTriggerSend the trigger to the whole session.triggerName: the name of the trigger to send.
SendTriggerSends a trigger to an InworldCharacter in the current scene.charID: The live session ID of the character to send. Send to World if it's empty
triggerName: The name of the trigger to send.
parameters: The parameters and their values for the triggers.
StartAudioSends AUDIO_SESSION_START control events to the server.
Without sending this message, all audio data would be discarded by the server.
However, if you send this event twice in a row, without sending StopAudio(), Inworld server will also throw exceptions and terminate the session.
StopAudioSends AUDIO_SESSION_END control events to Inworld server.
SendAudioSends the WAV data to the current character.
Ensure that an AUDIO_SESSION_START control event has been sent to the server.
Only the base64 string of the wave data is supported by the Inworld server. Additionally, the sample rate of the wave data must be 16000, mono channel.
base64: the base64 string of the wave data to send.
PushAudioManually pushes the audio wave data to the server.