Quest Generation (Domains)
Quest Generation (Domains)
Hello!
I'm trying to create some generated quest functionality in my game, and especially when the player is inside the dungeons. What I cannot understand after following the step by step documentation guide, is that I see the Quest Domains in 2D are marked easily, in 3D is the same method? I just create an empty object and selecting the area which is the Domain in a collider?? Also my dungeons are runtime generated, should I just save the domain in a prefab and spawn it after the dungeon is created? Is my workflow thinking correct?
I'm trying to create some generated quest functionality in my game, and especially when the player is inside the dungeons. What I cannot understand after following the step by step documentation guide, is that I see the Quest Domains in 2D are marked easily, in 3D is the same method? I just create an empty object and selecting the area which is the Domain in a collider?? Also my dungeons are runtime generated, should I just save the domain in a prefab and spawn it after the dungeon is created? Is my workflow thinking correct?
Re: Quest Generation (Domains)
Yes, that's all correct. 3D works the same as 2D. Your domain needs a trigger collider and a QuestDomain component with a DomainType asset assigned to it. Make sure the layers are set up to detect QuestEntities in the trigger collider. Prefabs are fine. You'll also want to assign the domain to one or more quest givers.
Re: Quest Generation (Domains)
figured it out
Re: Quest Generation (Domains)
One little issue I have is getting the domain in the Quest Giver after it instantiates (domain is on scene, the NPC prefab is not). If you have a small script to plug in the NPC to get the Domain or can guide me to make one would be nice. Thank you.
Re: Quest Generation (Domains)
Hi,
Add this script to your quest giver, and assign DomainType assets. It will find corresponding QuestDomains in Start. You can call its AddMyDomains() method manually if the QuestDomains aren't ready yet in Start.
FindQuestGiverDomains.cs
Add this script to your quest giver, and assign DomainType assets. It will find corresponding QuestDomains in Start. You can call its AddMyDomains() method manually if the QuestDomains aren't ready yet in Start.
FindQuestGiverDomains.cs
Code: Select all
using UnityEngine;
using PixelCrushers.QuestMachine;
using System.Collections.Generic;
[RequireComponent(typeof(QuestGeneratorEntity))]
public class FindQuestGiverDomains : MonoBehaviour
{
public List<DomainType> domainTypes;
void Start()
{
AddMyDomains();
}
public void AddMyDomains()
{
var generator = GetComponent<QuestGeneratorEntity>();
var domains = new List<QuestDomain>(generator.domains);
foreach (var domain in FindObjectsOfType<QuestDomain>())
{
var wantThisDomain = domainTypes.Contains(domain.domainType);
var alreadyHaveThisDomain = domains.Find(x => x.domainType == domain.domainType) != null;
if (wantThisDomain && !alreadyHaveThisDomain)
{
domains.Add(domain);
}
}
generator.domains = domains.ToArray();
}
}
Re: Quest Generation (Domains)
hmmm, can't get it to work, I put my domain type which is the same I have in the Domain that I have in the scene, I run it also manually, but still doesn't gets the domain gameobject in quest giver Domains. Thanks btw
Re: Quest Generation (Domains)
Are you sure the QuestDomains are in place before the script runs its AddMyDomains() method?
Also, make sure you're using the exact same DomainType asset in the QuestDomain and this script, not two separate assets that have the same name.
As a test to get an idea of how it works, you can open the Demo scene and clear the Knight's domains list. Add the script and assign the Field and Forest DomainTypes. When you play, the script should add the domains to the Knight's domains list. should
Also, make sure you're using the exact same DomainType asset in the QuestDomain and this script, not two separate assets that have the same name.
As a test to get an idea of how it works, you can open the Demo scene and clear the Knight's domains list. Add the script and assign the Field and Forest DomainTypes. When you play, the script should add the domains to the Knight's domains list. should
Re: Quest Generation (Domains)
Set the Quest Generator Entity's Domains > Size to zero, or add a null check in the script's loop.
Re: Quest Generation (Domains)
same, stays on 0