Multiple on conversation ends?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
annathehank
Posts: 95
Joined: Sun May 03, 2020 2:17 pm

Multiple on conversation ends?

Post 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;
            }
        }
    }


}
annathehank
Posts: 95
Joined: Sun May 03, 2020 2:17 pm

Re: Multiple on conversation ends?

Post 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
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Multiple on conversation ends?

Post 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.
annathehank
Posts: 95
Joined: Sun May 03, 2020 2:17 pm

Re: Multiple on conversation ends?

Post 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!
annathehank
Posts: 95
Joined: Sun May 03, 2020 2:17 pm

Re: Multiple on conversation ends?

Post 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.
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Multiple on conversation ends?

Post 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.
annathehank
Posts: 95
Joined: Sun May 03, 2020 2:17 pm

Re: Multiple on conversation ends?

Post 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!
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Multiple on conversation ends?

Post by Tony Li »

Glad to help! :-)
Post Reply