How To: Assign Quests At Start
Posted: Thu Aug 06, 2020 9:14 pm
This post describes one way to assign a random set of quests to the player at start:
1. Add a QuestGiver component to a GameObject, and assign quests to it.
2. Add a script with a Start() method similar to this:
1. Add a QuestGiver component to a GameObject, and assign quests to it.
2. Add a script with a Start() method similar to this:
Code: Select all
void Start()
{
var questGiver = GetComponent<QuestGiver>();
for (int i = questGiver.questList.Count - 1; i >= 0; i--) // Loop down in case quests are deleted from list.
{
// Flip a coin:
if (UnityEngine.Random.value < 0.5f)
{
var quest = questGiver.questList[i];
questGiver.GiveQuestToQuester(quest, "Player"); // Give quest to QuestJournal whose ID is "Player".
}
}
}