3D Quest objective marker?

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Strook
Posts: 70
Joined: Fri Nov 08, 2019 10:51 am

3D Quest objective marker?

Post by Strook »

Hello, I'm planning to add a feature to our game, which is a Quest objective marker: https://assetstore.unity.com/packages/t ... ors-153472

When you track a quest from your quest log, I want to display a 2d on screen marker, pointing to a specific location

What do you think would be the best way to do approach this system, knowing all my quest are using Dialogue System Quests.
Ideally I would like to have a location for each Quest entry, but Im not sure how and where to store this data (a gameobject from the scene? a "location" ?)

Thanks!
Currently working on ->Squeakross: Home Squeak Home<- Using Dialogue System Save System and other features.
Previous game made with Dialogue system ->The Spirit and The mouse<-
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: 3D Quest objective marker?

Post by Tony Li »

Hi,

You could add a script to the GameObject that has dropdowns for the quest and quest entry. Use [QuestPopup] and [QuestEntryPopup] attributes:

Code: Select all

public class QuestMarker : MonoBehaviour
{
    [QuestPopup] public string questName;
    [QuestEntryPopup] public int questEntry;
    
    private void Start()
    {
        UpdateMarker();
    }
    
    public void UpdateMarker()
    {
        if (QuestLog.IsQuestActive(questName) && QuestLog.GetQuestEntryState(questName, questEntry) == Quest.Active)
        {
            // Show marker
        }
        else
        {
            // Hide marker
        }
    }
}
In practical terms, you'll probably want to automatically update markers when quest entry states change. Ideally you'd register your markers with a manager script. But a quick-and-dirty first version could be:

Code: Select all

public class QuestMarkerManager : MonoBehaviour
{
    private void Awake()
    {
        QuestLog.SetQuestEntryStateOverride = SetQuestEntryStateAndUpdateMarkers;
    }
    
    private void SetQuestEntryStateAndUpdateMarkers(string questName, int entryID, string state)
    { // (Would be better for each QuestMarker to register itself in a list instead of FindObjectsOfType.)
        foreach (QuestMarker questMarker in FindObjectsOfType<QuestMarker>())
        {
            questMarker.UpdateMarker();
        }
    }
}
User avatar
Strook
Posts: 70
Joined: Fri Nov 08, 2019 10:51 am

Re: 3D Quest objective marker?

Post by Strook »

thanks for this solution, this seems very elegant!
Currently working on ->Squeakross: Home Squeak Home<- Using Dialogue System Save System and other features.
Previous game made with Dialogue system ->The Spirit and The mouse<-
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: 3D Quest objective marker?

Post by Tony Li »

Glad to help! Please let me know how it goes. I've added that asset to my list of things to look at. I might add official integration at some point.
Fitbie
Posts: 44
Joined: Tue Dec 07, 2021 6:30 pm

Re: 3D Quest objective marker?

Post by Fitbie »

I have question about quest manager - is it some event in Dialogue System telling listeners that any quest change its state?
Like watcher pattern with quests state
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: 3D Quest objective marker?

Post by Tony Li »

Hi,

Yes. The "OnQuestStateChange" message is sent to the Dialogue Manager GameObject's hierarchy.

You can add a script with an OnQuestStateChange(string questName) method to the Dialogue Manager, or add a Dialogue System Events component and configure its OnQuestStateChange() UnityEvent.
Fitbie
Posts: 44
Joined: Tue Dec 07, 2021 6:30 pm

Re: 3D Quest objective marker?

Post by Fitbie »

I have one more question :) I need to draw mark on map when player starts tracking some quest.
I know about OnQuestTrackingEnabled(string questTitle)
However, I don't want to write additional managers and I decided to extend your QuestStateListener by deriving
Since it is connected to QuestDispatcher and there is no OnQuestTrackingEnable there, I wanted to know how I can know when the player starts tracking the quest (to draw a mark on the map).
I tried (QuestLog.IsQuestTrackingEnabled(questName))
However, either this function just tells me if the quest can be tracked, or starting track quest does not trigger OnQuestStateChange in the dispatcher - nothing happens


I could extend Dispatcher and fix all of it, but then i need to override QuestStateDispatcher property in QuestStateListener, but its not virtual (bc i need to add my dispatcher with OnQuestTrackingEnabled, not yours)

Also i have variant manually add my custom dispatcher to dialogue manager GO, but it seems dirty.
I need tip from experienced developer :)
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: 3D Quest objective marker?

Post by Tony Li »

Hi,

QuestLog.IsQuestTrackingAvailable(questName) tells you if the quest is allowed to be tracked -- that is, if the quest log window shows a Track toggle that the player can turn on and off.

QuestLog.IsQuestTrackingEnabled(questName) tells you if the Track toggle has been turned on.
Fitbie
Posts: 44
Joined: Tue Dec 07, 2021 6:30 pm

Re: 3D Quest objective marker?

Post by Fitbie »

As far as I understand OnQuestStateChange() is not called when we start / stop tracking a quest. This is the responsibility of OnQuestTrackingEnabled() method
The only solution I can see is to modify the QuestStateDispatcher component and add the OnQuestTrackingEnabled/Disabled() method there, and also make the m_listeners field protected for deriving, instead of private so that I can send a message to the listeners (i need to know what listeners is). I know that changing your code is bad, but unfortunately with inheritance I can't get the m_listeners field

Or make another dispatcher for listening for OnQuestTrackingEnabled()
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: 3D Quest objective marker?

Post by Tony Li »

Hi,

This version of QuestStateDispatcher.cs will be in DS version 2.2.41. There is a public listeners property, and all methods are virtual.

DS_QuestStateDispatcherPatch_2023-10-29.unitypackage
Post Reply