Smart NPCs Quick Start Guide

Let's get started with adding voice to your game characters. This guide will show you how to implement Smart NPCs in your Unity project.

Adding Your First Smart NPC

You have two ways to implement a Smart NPC:

Method 1: Through Code

Create a new script (e.g., ExampleSmartNPC.cs) with this basic implementation:

using SkillfulAI.SmartNPCs;
using UnityEngine;

public class ExampleSmartNPC : MonoBehaviour
{
    private void Start()
    {
        // Add the Smart NPC component
        SmartNPC myNpc = gameObject.AddComponent<SmartNPC>();

        // Set a voice by category
        VoiceSelector.SetVoiceByCategory(myNpc, VoiceCategories.Female);

        // Set the output audio source for the NPC. 
        myNpc.audioSource = gameObject.AddComponent<AudioSource>();

        // Make the NPC speak!
        myNpc.Speak("Hello! I'm your first Smart NPC!");
    }
}

Method 2: Using the Unity Inspector

  1. Create an empty GameObject

  2. Add the SmartNPC component

  1. Add an AudioSource component (required for speech playback)

  2. Create a script to interact with it:

Voice Selection Options

Smart NPCs offers several ways to select voices:

Customizing Voice Settings

Fine-tune your NPC's voice characteristics:

Integrating with Skillful Agents

Create an NPC that can think and speak:

Managing Speech Queue

Handle multiple speech requests:

Creating a Basic Dialogue System

Implement a simple dialogue system:

Next Steps

Now that you have your Smart NPC working, consider:

  1. Experimenting with different voices and settings

  2. Creating more complex dialogue systems

  3. Implementing voice-based tutorials

  4. Adding ambient NPC chatter

  5. Creating voiced cutscenes

Check out the Service Reference for more detailed implementation options and advanced features.

Last updated