Skip to content

A flexible and extensible quest system for Unity games that supports multiple quest types, random generation, and reward distribution.

Notifications You must be signed in to change notification settings

wethecom/Unity-Automated-Quest-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

# Unity Quest System
A flexible and extensible quest system for Unity games that supports multiple quest types, random generation, and reward distribution.

## πŸ“‹ Table of Contents
- [Features](#features)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Components Overview](#components-overview)
- [Usage Examples](#usage-examples)
- [Customization](#customization)
- [Best Practices](#best-practices)
- [Troubleshooting](#troubleshooting)

## ✨ Features
- Multiple quest types (Collection, Elimination, Exploration, Escort, Delivery)
- Random quest generation with customizable parameters
- Dynamic reward system
- Quest tracking and progress management
- Event-driven architecture
- Player level scaling
- Location-based objectives
- Flexible reward system

## πŸš€ Installation

1. Create a new folder in your Unity project's Assets folder named `QuestSystem`
2. Copy the following scripts into the folder:
   - Quest.cs
   - QuestGenerator.cs
   - QuestTrigger.cs
   - QuestManager.cs
   - ItemReward.cs

## πŸƒβ€β™‚οΈ Quick Start

### Basic Setup

1. Create a new empty GameObject in your scene and name it "QuestSystem"
```csharp
GameObject questSystem = new GameObject("QuestSystem");
  1. Add the required components:

    • Add QuestManager component
    • Add QuestGenerator component
  2. Configure the QuestGenerator in the Inspector:

    • Add quest titles
    • Add quest descriptions
    • Configure possible rewards
    • Set experience and gold ranges

Setting Up Quest Givers

  1. Create an NPC or interaction point
  2. Add the QuestTrigger component
  3. Configure the trigger settings:
// In the Inspector
Interaction Range: 3
Interaction Key: E
Quest Available Indicator: [Assign your indicator prefab]

πŸ”§ Components Overview

Quest Manager

Controls the overall quest system:

// Get reference to Quest Manager
QuestManager questManager = FindObjectOfType<QuestManager>();

// Add a new quest
Quest newQuest = questManager.GenerateNewQuest();
questManager.AddNewQuest(newQuest);

// Complete a quest
questManager.CompleteQuest("questId");

// Update quest progress
questManager.UpdateQuestProgress("questId", 0, 1);

Quest Generator

Generates random quests:

// Configure in Inspector
[SerializeField] private List<string> questTitles;
[SerializeField] private List<string> questDescriptions;
[SerializeField] private List<ItemReward> possibleRewards;

Quest Trigger

Handles player interactions:

// Events you can subscribe to
onQuestOffered.AddListener(YourMethod);
onQuestAccepted.AddListener(YourMethod);
onPlayerEnterRange.AddListener(YourMethod);
onPlayerExitRange.AddListener(YourMethod);

πŸ’‘ Usage Examples

Creating a Basic Quest Giver

// 1. Create an NPC GameObject
GameObject npc = GameObject.CreatePrimitive(PrimitiveType.Capsule);
npc.name = "QuestGiver";

// 2. Add QuestTrigger component
QuestTrigger trigger = npc.AddComponent<QuestTrigger>();

// 3. Add Collider (if not present)
SphereCollider collider = npc.AddComponent<SphereCollider>();
collider.isTrigger = true;
collider.radius = 3f;

Listening for Quest Events

void Start()
{
    QuestManager questManager = FindObjectOfType<QuestManager>();
    
    questManager.onQuestAdded.AddListener(OnQuestAdded);
    questManager.onQuestCompleted.AddListener(OnQuestCompleted);
    questManager.onQuestFailed.AddListener(OnQuestFailed);
}

void OnQuestAdded(Quest quest)
{
    Debug.Log($"New quest added: {quest.title}");
    // Update UI or other game systems
}

🎨 Customization

Adding New Quest Types

  1. Add new type to QuestType enum:
public enum QuestType
{
    Collection,
    Elimination,
    Exploration,
    Escort,
    Delivery,
    YourNewType
}
  1. Add handling in QuestGenerator:
case QuestType.YourNewType:
    objectives.Add(new QuestObjective
    {
        description = "Your new objective",
        requiredAmount = Random.Range(1, 5),
        currentAmount = 0,
        isCompleted = false
    });
    break;

Customizing Rewards

// Create new reward types
[System.Serializable]
public class CustomReward : ItemReward
{
    public float specialBonus;
    public string uniqueEffect;
}

πŸ“ Best Practices

  1. Quest Design

    • Keep objectives clear and measurable
    • Balance rewards with quest difficulty
    • Use meaningful descriptions
    • Test quest completion conditions thoroughly
  2. Performance

    • Don't overuse quest triggers in a single scene
    • Clean up completed quests periodically
    • Use object pooling for quest markers
    • Implement proper save/load systems
  3. UI Integration

    • Create clear quest log interface
    • Show quest markers on minimap
    • Provide clear feedback for progress
    • Include quest tracking options

❗ Troubleshooting

Common Issues

  1. Quests not triggering

    • Check if QuestSystem GameObject is in the scene
    • Verify QuestTrigger collider settings
    • Ensure player has "Player" tag
  2. Rewards not distributing

    • Check QuestManager reference
    • Verify reward values in Inspector
    • Debug reward distribution method
  3. Quest progress not updating

    • Verify quest ID matches
    • Check objective index
    • Ensure progress values are correct

Debug Tips

// Add to QuestManager
[SerializeField] private bool debugMode = false;

private void DebugLog(string message)
{
    if (debugMode)
        Debug.Log($"[Quest System]: {message}");
}

πŸ”„ Updates and Maintenance

To update the system:

  1. Backup your current quest data
  2. Update script files
  3. Test in a development scene
  4. Check for any breaking changes
  5. Update existing quests if needed

πŸ“¦ Additional Resources

  • Create UI prefabs for quest notifications
  • Design quest marker icons
  • Implement sound effects for quest events
  • Add particle effects for quest completion

🀝 Contributing

Feel free to:

  • Report bugs
  • Suggest improvements
  • Add new features
  • Share your customizations

πŸ“„ License

This quest system is available under the MIT License. Feel free to use and modify it in your projects.


This README provides a comprehensive guide for implementing and using the quest system. Would you like me to expand on any particular section or add more specific examples?

About

A flexible and extensible quest system for Unity games that supports multiple quest types, random generation, and reward distribution.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages