In the Inspector
Without code: add an entry under Game actions the character can use.In code, with arguments
- An
ActionParamis 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 rawJson), 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:
SetContext.