Quest is not shown in journal

Announcements, support questions, and discussion for Quest Machine.
Post Reply
dkrusenstrahle
Posts: 39
Joined: Sat Apr 20, 2024 7:03 pm

Quest is not shown in journal

Post by dkrusenstrahle »

Hello,

I followed the video guide and setup a handwritten quest.
The whole flow seems to work. I setup a quest giver that gives the player a quest that the player accepts and I can go to the "circle" and complete the quest and all HUD and other UI elements are showing the progress, the problem is that there are nothing in the journal about the quest (I have added text to all parts of the setup which belongs to journal and so on).

I have also added a Quest Journal to the Player. But nothing shows up in the Journal UI component.
User avatar
Tony Li
Posts: 22106
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest is not shown in journal

Post by Tony Li »

Hi,

Are there any errors or warnings in the Console window?

When you pick up the quest while playing the scene in the Unity editor's play mode, inspect the player's Quest Journal component. Does its Quests list contain the quest?

Make sure to leave the Quest Journal component's UI Settings > Quest Journal UI field UNassigned. This way it will use the quest journal UI assigned to the Quest Machine GameObject, which is the easiest way to set things up.
dkrusenstrahle
Posts: 39
Joined: Sat Apr 20, 2024 7:03 pm

Re: Quest is not shown in journal

Post by dkrusenstrahle »

No errors.

The quest is listed in the player's Quest Journal component.
Quest Journal component's UI Settings > Quest Journal UI field is Unassigned.

Is there a way to access the journal programmatically? Like you showed me here:

https://www.pixelcrushers.com/phpbb/vie ... php?t=8094
Attachments
Screenshot 2024-04-22 at 17.40.59.png
Screenshot 2024-04-22 at 17.40.59.png (10.98 KiB) Viewed 1296 times
User avatar
Tony Li
Posts: 22106
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest is not shown in journal

Post by Tony Li »

Hi,

Yes, you can access the player's journal like this:

Code: Select all

QuestJournal journal = QuestMachine.GetQuestJournal();
foreach (Quest quest in journal.questList)
{
    Debug.Log($"quest {quest.id} state: {quest.GetState()}");
}
It sounds like you're following the video tutorials. If you download and import the tutorial assets and play the completed scene, does everything show up as expected in the UIs? If so please compare the quests to yours. Maybe the text ended up in the wrong place, such as the quest nodes' Inactive states instead of the Active or True states.
dkrusenstrahle
Posts: 39
Joined: Sat Apr 20, 2024 7:03 pm

Re: Quest is not shown in journal

Post by dkrusenstrahle »

I tried your code and it displays the quests in the journal if I use the below code.

Code: Select all

using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
using PixelCrushers.QuestMachine;
public class UIQuestsList : MonoBehaviour
{
    [SerializeField] private GameObject itemPrefab;
    [SerializeField] private Transform listParent;

    private void OnEnable()
    {
        ClearList();
        GenerateReport();
    }

    private void GenerateReport()
    {
        QuestJournal journal = QuestMachine.GetQuestJournal();
        foreach (Quest quest in journal.questList)
        {
            Debug.Log($"quest {quest.id} state: {quest.GetState()}");
            GameObject itemRow = Instantiate(factionMemberPrefab, listParent);
            itemRow.transform.Find("ItemName").GetComponent<Text>().text = $"{quest.id}";
            itemRow.transform.Find("Status").GetComponent<Text>().text = $"{quest.GetState()}";
        }
    }

    private void ClearList()
    {
        foreach (Transform child in listParent)
        {
            Destroy(child.gameObject);
        }
    }

}

What else can I get from quest in the loop? DisplayName? Something else?
User avatar
Tony Li
Posts: 22106
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest is not shown in journal

Post by Tony Li »

You can get everything. :-)

Here's the API page for the Quest object: Quest
dkrusenstrahle
Posts: 39
Joined: Sat Apr 20, 2024 7:03 pm

Re: Quest is not shown in journal

Post by dkrusenstrahle »

Ah great, that will be handy.

I am trying to get quest giver object, how can I get that?
User avatar
Tony Li
Posts: 22106
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest is not shown in journal

Post by Tony Li »

Hi,

Use QuestMachineMessages.FindGameObjectWithID():

Code: Select all

GameObject npc = QuestMachineMessages.FindGameObjectWithID(quest.questGiverID);
dkrusenstrahle
Posts: 39
Joined: Sat Apr 20, 2024 7:03 pm

Re: Quest is not shown in journal

Post by dkrusenstrahle »

A brilliant, will try it out.

Thank you!
User avatar
Tony Li
Posts: 22106
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest is not shown in journal

Post by Tony Li »

Glad to help!

You can use the same QuestMachineMessages.FindGameObjectByID() method to find a GameObject by the ID assigned to the Quest Journal component, Quest Giver component, Quest Entity component (for procedural quest generation), or Quest Machine ID (a simple component that just adds an ID to the GameObject.)
Post Reply