Creating an AI NPC¶
In this tutorial, you will learn how to create a non-playable character (NPC) with advanced artificial intelligence (AI) with an assembler. This NPC has the capability to engage in interactions with the player, similar to the AI-generated characters in our game, AI Asylum.
Make sure that you have the latest version of YAHAHA Studio (0.3.66 or later).
Create an AI NPC¶
Before you start creating an interactive AI NPC with an assembler, note that you have two options: using a pre-set AI NPC (smart asset) or combining your own NPC model with key features of your published custom AI Asylum character.
Add the assembler¶
- Find the Create an AI NPC assembler from Asset Library and open it in the scene.
- In the assembler setup window, finish its basic settings as in the next section.
Set up the assembler¶
Choose how to create your AI NPC in the Choose the method for creating your AI NPC:
- Use a preset AI NPC allows you to use a pre-made AI NPC from YAHAHA.
- Create by myself allows you to use your own NPC model and leverage key features of your custom AI Asylum character providing its ID.
In our case, we want to use a preset official AI NPC.
Select an AI NPC from available options. These options are smart assets, which are already complete with predefined character backstories and favor score systems that that represent the NPCs' contentment level. To find more, go to Collections by YAHAHA>AI Game Jam>AI NPC Smart Assets in Asset Library. For example, we choose Mio as the AI NPC.
Note: If you choose to create from scratch, you can look for a NPC model in the Character Model folder of the AI Game Jam. For the character ID, it is exclusive to a game character you created and published in AI Asylum. By attaching it to your NPC, the NPC inherits a character backstory and the favor score system. To find the character ID, click + Write your own stories in the game to access the modding interface, then locate the character in My Patients.
(Optional) Select Use GPT-3.5 for your AI NPC.
(Optional) Enter your OpenAI API key in the following input field which is only visible when you choose to use GPT-3.5.
In the Configure the AI trigger-event list, you can click the + plus button to add a trigger event and provide a name for the triggered even if needed. When using your own model, this step is necessary as it enable your NPC to listen to, customize, and send trigger events and become interactive with other objects in the scene.a Trigger event: Select one of the following events as a trigger:
b Triggered event: Enter a name for the triggered event.
- Emotion 1-10 represents the AI NPC's favor score, ranging from 10% to 100%. It reflects the NPC's contentment level, with 10 being the least content and 100 being the most content.
- Chat Win indicates that the player wins the chat interaction with the AI NPC.
- Chat Lose indicates when the player loses the chat interaction with the AI NPC.
Click Assemble to initiate the setup process for this AI NPC. Once the NPC is assembled, you will be able to modify its properties in the Properties window. In addition, to facilitate future management, you can change the AI NPC's name from MiaoNiang Variant (asset name) to Mio (character name) in the Objects Explorer.
Edit an AI NPC¶
In the Properties window, a series of components are combined to assemble the AI NPC. All mentioned components can be found via + Feature or Asset Library.
For example, by going to + Feature>Gameplay, you can find and add the NPC feature with following properties:
|The name for your AI NPC
|The unique identifier of your AI NPC based on the order it was created. It cannot be changed.
In Asset Library, go to Collections by YAHAHA>AI Game Jam>AI Components for AI NPC, you will locate all related AI components used in this Create an AI NPC assembler.
Note: If you attach multiple assemblers to the AI NPC you created, all assemblers connected to the same trigger will be executed simultaneously.
Now it's time to playtest your AI NPC in Play Mode!