Skip to main content
An action is a function of your game that the character can decide to call: sell an item, open a gate, start a quest, get angry. It is a tool call of the voice agent, set up from the game.

In the Inspector

Without code: add an entry under Game actions the character can use.

In code, with arguments

  • An ActionParam is a name, a description, a type (String, Number, Integer, Boolean), whether it is required, and the values allowed, if they are few.
  • The handler runs on the main thread with the arguments the character chose (GetString, GetInt, GetNumber, GetBool, Has, or the raw Json), and returns a sentence saying what happened. The character answers with it, so write facts: what changed, what failed and why.
  • Check the arguments. They come from a language model: an item that does not exist, a price it made up. The game decides; the sentence tells the character.

Actions that take time

AddActionAsync takes a handler that awaits. The character waits for the result, and stays in Thinking:
Keep it to a few seconds. For something longer, return at once (“On my way.”) and tell the character later with SetContext.

During the game

Actions can be added and removed at any time; the character knows from its next reply.
An action that is not there cannot be called, which is a better lock than a sentence in the persona.

Reactions

An action does not have to change the world. One that only tells the game how the character feels drives its face and body:
Game characters puts this together with animation.

Test them without talking

The handler is a function: call it. To check that the agent is told what you think, run the conversation against the mock server.