Page 1 of 1

Quest is not shown in journal

Posted: Mon Apr 22, 2024 10:35 am
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.

Re: Quest is not shown in journal

Posted: Mon Apr 22, 2024 11:28 am
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.

Re: Quest is not shown in journal

Posted: Mon Apr 22, 2024 11:43 am
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

Re: Quest is not shown in journal

Posted: Mon Apr 22, 2024 12:07 pm
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.

Re: Quest is not shown in journal

Posted: Mon Apr 22, 2024 12:21 pm
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?

Re: Quest is not shown in journal

Posted: Mon Apr 22, 2024 12:37 pm
by Tony Li
You can get everything. :-)

Here's the API page for the Quest object: Quest

Re: Quest is not shown in journal

Posted: Mon Apr 22, 2024 1:57 pm
by dkrusenstrahle
Ah great, that will be handy.

I am trying to get quest giver object, how can I get that?

Re: Quest is not shown in journal

Posted: Mon Apr 22, 2024 4:36 pm
by Tony Li
Hi,

Use QuestMachineMessages.FindGameObjectWithID():

Code: Select all

GameObject npc = QuestMachineMessages.FindGameObjectWithID(quest.questGiverID);

Re: Quest is not shown in journal

Posted: Mon Apr 22, 2024 4:38 pm
by dkrusenstrahle
A brilliant, will try it out.

Thank you!

Re: Quest is not shown in journal

Posted: Mon Apr 22, 2024 4:42 pm
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.)