OnVisualizeQuest

Announcements, support questions, and discussion for Quest Machine.
Post Reply
Fax
Posts: 15
Joined: Fri Mar 19, 2021 4:40 am

OnVisualizeQuest

Post by Fax »

Hi everybody.
I want to know if there is a way to catch when a quest is visualize.
When a player is asking for a quest (which is waiting to start), just before the player accept the quest.
I want to play some audio clip on top of the text.

Thanks a lot if someone can help me.
Fax
Posts: 15
Joined: Fri Mar 19, 2021 4:40 am

Re: OnVisualizeQuest

Post by Fax »

I'm getting a headache...
I search for a way to get current quest and current node which is display.

I can script over QuestMachine code but, dunno where i'm suppose to get these informations cause of the specific structure of QuestMachine.
User avatar
Tony Li
Posts: 21926
Joined: Thu Jul 18, 2013 1:27 pm

Re: OnVisualizeQuest

Post by Tony Li »

Hi,

What if you add Audio Quest Content to the quest's Offer Text?

offerTextAudio.png
offerTextAudio.png (32.71 KiB) Viewed 922 times
Fax
Posts: 15
Joined: Fri Mar 19, 2021 4:40 am

Re: OnVisualizeQuest

Post by Fax »

I can't because i use Localization for sounds (an a Manager for that).

I want to trigger a scene event at the same place as your audio clip is triggered.

Edit : Like a "Offer Action".
User avatar
Tony Li
Posts: 21926
Joined: Thu Jul 18, 2013 1:27 pm

Re: OnVisualizeQuest

Post by Tony Li »

Hi,

You can write a custom quest content script. Duplicate QuestContentTemplate.cs and rename it something like LocalizedAudioQuestContent.cs. Then fill in your code where the comments indicate. Quest Machine will automatically recognize your script and make it available in dropdown menus.
Fax
Posts: 15
Joined: Fri Mar 19, 2021 4:40 am

Re: OnVisualizeQuest

Post by Fax »

I'll try it in couple of minutes and let you know after.
Thanks a lot again for your help.
Fax
Posts: 15
Joined: Fri Mar 19, 2021 4:40 am

Re: OnVisualizeQuest

Post by Fax »

I don't understand where i have to put my code.
The template show us 6 possibilities to uncomment, but no one is triggered when i open the offer quest.
I am missing something somewhere but dunno what and where.
2021-04-16_15h40_19.png
2021-04-16_15h40_19.png (34.42 KiB) Viewed 917 times
Fax
Posts: 15
Joined: Fri Mar 19, 2021 4:40 am

Re: OnVisualizeQuest

Post by Fax »

Finally found a solution.
First there is my custom QuestContent :
2021-04-16_16h40_10.png
2021-04-16_16h40_10.png (6.28 KiB) Viewed 917 times
In second time, i had to add this condition to trigger my QuestContent at the right moment (in UnityUIBaseUI.cs) :
2021-04-16_16h40_24.png
2021-04-16_16h40_24.png (26.46 KiB) Viewed 917 times
Finally, i create in UnityUIBaseUI.cs a method to redirect to my custom QuestContent :
2021-04-16_16h40_50.png
2021-04-16_16h40_50.png (5.3 KiB) Viewed 917 times
Don't know if this is the cleaner way but it works for my purpose.
Thanks again for your help.
User avatar
Tony Li
Posts: 21926
Joined: Thu Jul 18, 2013 1:27 pm

Re: OnVisualizeQuest

Post by Tony Li »

Hi,

That will work. If you have directly modified UnityUIBaseUI.cs, I recommend making a subclass instead. Example:

Code: Select all

public class MyQuestDialogueUI : UnityUIQuestDialogueUI
{
    protected virtual void AddContent(QuestContent content)
    {
        if (content is LocalizsedAudioQuestContent)
        {
            AddLocalizedAudioContent(content as LocalizedAudioQuestContent)
        }
        else
        {
            base.AddContent(content);
        }   
    }
    
    protected virtual void AddLocalizedAudioQuestContent(LocalizedAudioQuestContent localizedAudioQuestContent)
    {
        if (localizedAudioQuestContent == null || localizedAudioQuestContent.index == -1) return;
        localizedAudioQuestContent.Play();
    }
}
Then use MyQuestDialogueUI on your quest dialogue UI instead of UnityUIQuestDialogueUI. To replace the script in-place, change the Inspector view to Debug, and then drag your MyQuestDialogueUI script into the UnityUIQuestDialogueUI component's Script field.
Post Reply