Skip to main content
The MassAI Template is a powerful demo that shows how to generate tons of Inworld-powered characters using Unreal’s Mass Entity System. It also provides a clear C++ example of how to use the Inworld Graph directly in your code.

Run the MassAI Sample Level

  1. Open the settings menu in the Content Browser within Unreal.
  2. Enable the option for “Show Plugin Content”.
  3. In the Content Browser, navigate to /Plugins/InworldMassAI.
  4. Double-click on the InworldMassDemo map.
  5. Click the Play-in-Editor button (alt+p) to launch your level.
  6. Have a conversation with any character closest to you!

Template Overview

The MassAI template provides a powerful system for creating large-scale AI-powered Inworld characters in your scene using the MassSpawner entry point. This template demonstrates how to spawn and manage multiple AI characters efficiently using Unreal’s Mass Entity System. This template also covers how to set up the necessary assets for the MassSpawner, including the MassEntityConfig and EQS_SpawnEntity configurations.
To send a message to the characters, you can either:
  1. Type your message in the text box and press enter (or click the send button).
  2. Talk using your microphone. Simply click the microphone icon at the left end of the text box to toggle the microphone on or off.
    Microphone OffMicrophone On
    The audio capture component will automatically detect when you have completed your message and send the message to the conversation target.
A speech bubble will appear above the character’s head and they will generate a response.

MassSpawner Configuration

The MassSpawner is the entry point for spawning multiple AI characters in your scene. When you place a MassSpawner actor in your level, it automatically initializes and spawns entities based on your configuration. The spawner reads the MassEntityConfig to determine what components and traits each entity should have, then uses the EQS_SpawnEntity generator to figure out where to place them in the world. To configure the MassSpawner, select it in the World Outliner and adjust its properties in the Details panel.

Count

The Count property determines how many entities the spawner will create. This is a simple integer value, set it to the number of AI characters you want in your scene. For example, setting it to 20 will spawn 20 Inworld-powered characters when the level starts.

Entity Config

The Entity Types array lets you specify which MassEntityConfig asset to use for spawning entities. Each entry in the array contains:
  • Entity Config: A reference to a MassEntityConfig asset that defines what components and traits each spawned entity will have
  • Proportion: A weight value (typically 1.0) that determines the relative probability of this entity type being spawned when multiple types are defined
The MassEntityConfig asset is a standard Mass Entity System configuration that defines the components and fragments that make up an entity. Most of the configuration in MassEntityConfig follows standard Mass Entity System patterns, things like transform components, level of details(LOD), and other gameplay-related fragments are configured here as they would be for any Mass entity. However, the Inworld Character Traits fragment is what makes these entities into AI-powered Inworld characters. This fragment is specific to the Inworld integration and contains the essential configuration for connecting each spawned entity to the Inworld AI system.
Inworld Character Traits
The Inworld Character Traits fragment is where you configure the Inworld-specific properties for each spawned character. In this demo, the trait system supports batch generation and configuration of Character Profile and Voice settings for each spawned entity. The trait fragment contains:
  • CharacterProfile : The character profile data that defines the character’s personality, backstory, and behavioral traits.
  • Voice : The voice configuration that determines how the character’s speech is synthesized and played back.
    For more information on how to configure a character, see the Character template.
When the MassSpawner creates entities, it applies the Inworld Character Traits fragment to each one, which automatically sets up the necessary Inworld components and registers the character with the conversation system. This allows each spawned entity to function as a fully interactive AI character that can respond to player input and participate in conversations. The actual configuration and initialization of these traits happens in C++ code. To understand how traits are defined and how the initialization process works, you can examine the source files:
  • Source/InworldMassAI/Public/InworldMassAITypes.h - See how traits are defined in the trait structure
  • Source/InworldMassAI/Public/InworldCharacterTrait.h - See how traits are initialized when entities are spawned

Spawn Data Generators

The Spawn Data Generators array determines where entities will be placed in the world. In this demo, the EQS_SpawnEntity generator uses a “Donut” pattern to spawn characters in concentric rings around the querier (typically the player or spawner location), with configurable inner and outer radii, number of rings, and points per ring. Beyond this pattern, EQS generators can also spawn entities based on navigation meshes, random points, grid patterns, or custom query logic to suit different gameplay scenarios.

Graph

This template uses an Inworld graph to generate character profiles dynamically at runtime. Let’s walk through how this graph works. The graph starts with an input node (denoted by the blue arrow), which allows you to pass an integer variable at runtime. This value is determined by the type specified in the Details panel and represents the number of characters to generate. This integer value is then passed to a custom node called InworldNode_GeneratorPrompt. This custom node constructs a prompt that instructs the LLM to randomly generate character profile information, including attributes like name, job, backstory, gender, personality traits, and example dialogue. The generated prompt is then sent to the LLM node, which processes the request and generates a response. The response is passed through the LLMResponse To Text node to convert it into plain text format, which contains the JSON-formatted character data. The logic for compiling the Inworld Graph, executing it, and retrieving the results is implemented in C++ code. To understand how to use C++ to compile and execute Inworld Graphs, you can examine the source files:
  • Source/InworldMassAI/Public/InworldMassAIGraphExecutor.h and Source/InworldMassAI/Private/InworldMassAIGraphExecutor.cpp - See how the graph is compiled and executed, and how results are handled