NPC data can be stored inside ScriptableObjects instead of hardcoding values inside MonoBehaviours. This approach keeps projects organized, reusable, and easy to maintain.
- Centralized NPC configuration
- Easy balancing without changing code
- Better project organization
- Reusable data across multiple prefabs
- Designer-friendly workflow
- NPC Name
- Health
- Damage
- Movement Speed
- Attack Range
- Experience Reward
- Character Icon
- Create an NPC ScriptableObject.
- Create NPC data assets.
- Assign data assets to NPC prefabs.
- Read the data at runtime.
- Store only configuration data.
- Avoid runtime state inside ScriptableObjects.
- Organize assets into folders.
- Use clear naming conventions.
- Validate values before publishing.
Using ScriptableObjects for NPC data makes Unity projects cleaner, easier to scale, and much simpler to maintain as your game grows.