Smart NPCs Service Reference
Smart NPCs Service ReferenceThis reference guide covers the essential components and usage patterns of the Smart NPCs service, focusing on practical implementation details.
Core Components
Core ComponentsSmartNPC Component
The primary component for adding voice capabilities to your game objects. This component handles:
Voice selection and management
Speech generation and playback
Audio queue management
Voice parameter customization
Implementation Patterns
Implementation PatternsBasic NPC Pattern
Basic NPC PatternSimplest implementation for a speaking character:
using SkillfulAI.SmartNPCs;
using UnityEngine;
public class BasicNPC : MonoBehaviour
{
private SmartNPC npc;
void Start()
{
// Basic setup
npc = gameObject.AddComponent<SmartNPC>();
VoiceSelector.SetVoiceByCategory(npc, VoiceCategories.Male);
npc.audioSource = gameObject.AddComponent<AudioSource>();
}
public void Speak(string text)
{
npc.Speak(text);
}
}Intelligent Speaking NPC Pattern
Intelligent Speaking NPC PatternCombining Smart NPCs with Skillful Agents:
Multi-Voice Manager Pattern
Multi-Voice Manager PatternFor managing multiple NPCs with different voices:
Dialogue System Pattern
Dialogue System PatternFor handling complex dialogue sequences:
Interactive Tutorial Pattern
Interactive Tutorial PatternFor creating voiced tutorials:
Best Practices
Best PracticesVoice SelectionChoose appropriate voices for character types
Keep voice settings consistent for each character
Consider using voice categories for consistency
Speech ManagementDon't overlap speech from the same NPC
Implement proper queue management
Consider adding speech cooldowns
PerformanceReuse SmartNPC components
Manage audio resources properly
Implement proper cleanup.
Last updated