Page 1 of 1

Multiple on conversation ends?

Posted: Mon May 17, 2021 12:23 pm
by annathehank
Hello Again <3

I was wondering if there was any kind of issue with having a few different system triggers set to go off on conversation end.

I have three achievements that can unlock during a conversation, but I wasn't sure how to use the script I wrote to turn them on from the dialogue manager/conversation node, so I figured I'd do three on conversation ends depending on which choice you picked (setting a variable to use as a condition when the player selects a choice) and then use the on execute command to run my script.
I also have a continute button that I would like to appear when the conversation is over so that the player can move to the next scene.

However, after testing this, it didn't look like the achievement had been set and the button did not appear. I'm curious if there's some kind of issue with having more than one thing set to go when a conversation ends?

(This is the script I use to activate achievements if it helps)

Code: Select all

using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;


public class AchActivation : MonoBehaviour
{
  
    // Start is called before the first frame update
    void Start()
    {
        var AchObjects = GameObject.FindGameObjectsWithTag("Ach");

        foreach (GameObject achievements in AchObjects)
        {
            achievements.GetComponent<AchHolder>().AllCode = PlayerPrefs.GetInt(achievements.GetComponent<AchHolder>().Name);
            
            if(achievements.GetComponent<AchHolder>().AllCode == 1)
            {
                achievements.GetComponent<AchHolder>().Active.SetActive(true);
                achievements.GetComponent<AchHolder>().InActive.SetActive(false);
            }

                  
        }
    }
    public void UnlockAch(string achName)
    {
        var AchObjects = GameObject.FindGameObjectsWithTag("Ach");
        foreach (var achievements in AchObjects)
        {
            if (achievements.GetComponent<AchHolder>().Name == achName)
            {
                achievements.GetComponent<AchHolder>().AllCode = 1;
                PlayerPrefs.SetInt(achievements.GetComponent<AchHolder>().Name, achievements.GetComponent<AchHolder>().AllCode);
                achievements.GetComponent<AchHolder>().ThisCode = 1;
            }
        }
    }


}

Re: Multiple on conversation ends?

Posted: Mon May 17, 2021 12:52 pm
by annathehank
Update:

I figured out why the button wasn't appearing (because I had the trigger on it and it wasn't active at the start so it wasn't triggering it)

But I'm still having trouble getting the achievements to work, so it may not be an issue with having the different triggers

Re: Multiple on conversation ends?

Posted: Mon May 17, 2021 12:57 pm
by Tony Li
Hi,

You can have as many On Conversation Ends as you want. Note that On Conversation End is only sent to the Dialogue Manager, the two primary participant GameObjects, and their children. Make sure you've put your Dialogue System Triggers on the GameObjects that will be used as the conversation's Conversation Actor or Conversation Conversant. (More info: Character GameObject Assignments)

If you think they're already set up like that, then after the conversation inspect the Conditions sections of each of the Dialogue System Triggers. If they received OnConversationEnd, they willl show (Last Check: True) or (Last Check: False). If you don't see either of those, then they did not receive OnConversationEnd.

If you think the triggers are set up right, perhaps add some Debug.Log lines to your achievements code to make sure it's getting called.

Re: Multiple on conversation ends?

Posted: Mon May 17, 2021 1:19 pm
by annathehank
Ah thank you! Good to know!

I think it's something wrong with my script
Which is very weird because it was working fine the last time I checked it and I didn't really change anything to it :lol:

I added an else to the if statement to UnityEngine.Debug.Log("no") but neither the achievement goes active nor does the consol write the command so...I think something is definitely off here and I'll have to go investigating!

Re: Multiple on conversation ends?

Posted: Mon May 17, 2021 1:23 pm
by annathehank
Oh I think I figured it ou!!!
I keep using pop up panels and hiding them from screen and NOT REMEMBERING that an inactive object won't activate things.

Re: Multiple on conversation ends?

Posted: Mon May 17, 2021 1:41 pm
by Tony Li
Sounds like you got it.

One trick for UIs is that you can hide a UI by disabling its Canvas component. The GameObjects will remain active; it simply won't draw on the screen.

Re: Multiple on conversation ends?

Posted: Tue May 18, 2021 10:06 am
by annathehank
ohhhhh my gosh thank you!!! For some reason, the weird logic in my brain was like 'you can only have one canvas' so I didn't even think I could do that :lol:

Thank you for all your help with everything <3 You are a rock star!

Re: Multiple on conversation ends?

Posted: Tue May 18, 2021 10:34 am
by Tony Li
Glad to help! :-)