Skip to main content

Demo: 2D

This demo is under Assets > Inworld > Inworld.AI, also included in the InworldAI.Lite package.

1. Typing to the character

You can type sentences, and press the "Enter" or Send button, to send message to the character.

Sample2D1

2. Speech to Text

Alternatively, you can hold down the Record button, speak your message, and then release Record to send a voice message.

⚠️ Note: If you are building a WebGL application, the microphone is not supported, so the Push-to-talk feature is not available either.

Sample2D2

3. Description

This 2D scene is very simple. There are only two GameObjects: PlayerController2D and InworldController.

PlayerController2D

We inherited PlayerController2D from PlayerController and registered the OnCharacterRegistered event. This allows it to instantiate a Character Selector button whenever a character is registered in the Inworld scene, enabling you to choose which character you would like to interact with.

Player2D

InworldController

As for the InworldController, we keep it as it is.

Controller2D

Character

In this sample 2D scene, instead of instantiating all characters in the scene on Start, whenever we click a character's selector button on the left, we will first instantiate that character if it does not already exist, and then select that character for interaction.

Controller2D