Page 1 of 1

Problem with QuestDomain

Posted: Fri Mar 19, 2021 10:19 am
by AArtlone
Hi!

I continue exploring the QuestMachine and today I have faced a small problem with QuestDomain.

My problem was the following:
  • There is an NPC game object in the scene
  • The game object has a Collider and the QuestDomain component
  • I then use this QuestDomain as a reference in some other script, and I add entities when needed
  • But today I noticed that if any other entity collides with the NPC, it would be added to the QuestDomain
  • This is because QuestDomain script uses OnTriggerEnter
This is not something that I would want to happen. One reason is that in general, I do not want to add Entities when a collision happens, instead, I want to control it from somewhere else. Besides, both OnTriggerEnter and OnTriggerExit call GetComponentInChildren, which is something we try to avoid using.

Also, in the manual you say:
  • "Domains don't always have to represent physical
    areas; they can represent anything that can contain quest entities, such as a character's inventory"
How can you then have a non-physical representation of the domain, if the QuestDomain component has OnTrigger methods?

The only way to represent the domain in the scene is by having a QuestDomain component on one of the game objects, right?

What if I want to have a character game object, that has a collider component and a QuestDomain component. But I don't want every entity that the character collides with to be added to this QuestDomain. How would I achieve this?

One way would be to ensure that the game object that has the QuestDomain component, does not have a Collider component. But this does not seem like a reliable solution.

Perhaps I am missing something. Looking forward to your response.

Artem

Re: Problem with QuestDomain

Posted: Fri Mar 19, 2021 11:19 am
by Tony Li
Hi Artem,

The purpose of the QuestDomain component is to identify entities that are in a trigger area so they can be considered for quests.

If you don't want to do that, here are two options:

1. Remove the collider and manually add an remove entities using QuestDomain.Add/RemoveEntity. (As you mentioned.)

2. Or remove the QuestDomain component entirely. Assign an event handler to the NPC's QuestGeneratorEntity.updateWorldModel event. Manually add facts to the world model. Example:

Code: Select all

GetComponent<QuestGeneratorEntity>().updateWorldModel += OnUpdateWorldModel;

void OnUpdateWorldModel(WorldModel worldModel)
{
    worldModel.AddFact(new Fact(domainType, entityType, count));
}

Re: Problem with QuestDomain

Posted: Mon Mar 22, 2021 7:42 am
by AArtlone
Hmmm, I see. Thanks for the example!