In the example scene below, the Villager has a new quest called "Random Delivery" that asks the player to deliver a package to the Carrot Field or the Orc Forest:
QM_RandomLocationQuestExample_2025-05-25.unitypackage
Here's how it's set up:
1. The example scene has two new trigger areas: Carrot Field and Orc Forest. When the player enters these trigger areas, a Trigger Event component calls QuestControl.SendToMessageSystem with "Entered" + "Carrot Field" or "Orc Forest".
2. The example adds a new custom quest action named RandomLocationQuestAction. The quest's Waiting To Start > Actions list uses this action to set the value of a tag named "{location}" to either "Carrot Field" or "Orc Forest". (Every quest has a dictionary of tag values that you can add to at runtime.) The custom action script is:
Code: Select all
using UnityEngine;
using System.Collections.Generic;
namespace PixelCrushers.QuestMachine
{
public class RandomLocationQuestAction : QuestAction
{
public List<string> locations;
public override void Execute()
{
base.Execute();
var randomLocation = locations[Random.Range(0, locations.Count)];
quest.tagDictionary.dict["{location}"] = randomLocation;
}
}
}