Dialogue System Event not firing

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
igorsandman
Posts: 35
Joined: Fri Jul 09, 2021 9:50 am

Dialogue System Event not firing

Post by igorsandman »

Hi,
I'm having an issue with Dialogue System Events. On some conversations, the events aren't triggering.

My game was working fine with DS Events until recently, but now every new dialogue that I create doesn't trigger the events. The older dialogues still work fine. Only newly created conversations bug. I don't know if it's something I changed, since the old dialogues still work. I updated DS recently, which might have been the cause, but I had a back up of my project with the older version of the asset. I tried bringing it back to my project and the issue is still there.

When I start a dialogue, the OnUse() is called, and the first line of dialogue is played, but the event OnDialogueStart isn't launched. No error in the log.

Here is my log. I have a DebugLogError in my function that reacts to OnDialogueStart and as you can see it doesn't display. (it does display in the convo that works)
DS_events_issue.jpg
DS_events_issue.jpg (178.9 KiB) Viewed 429 times
Here are the thigs I tried as I was debugging it:
Changing the actor, with the same conversation (events don't fire)
Changing the conversation to a test convo for the same actor (events don't fire)
Renaming its conversation (events don't fire)
Giving this NPC a random existing conversation that I know works (events fire)
Giving another NPC this same dialogue and actor (events don't fire)
Creating a new NPC and giving it an old conversation that I know works (events fire)
I tried replaying my game from earlier to make sure the issue isn't in my save state (events don't fire)
I tried creating a new dialogue that starts with the player character speaking.(events don't fire)

Do you have any idea where I should look?

On a side not, here are a couple of previous issue that might or might not be related:
Issue 1: A couple of weeks ago I tried to add a new Dialogue System Event component to another game object (Previously I only had one on the Character Controller). Those events didn't fire even though the ones on the Character Controller did fire. At the time, I put that bug on my back log and called my functions from Character Controller since I knew it worked. Now that I have another issue with DS Events, I'm thinking maybe the issues are related.

Issue 2: This might have nothing to do with it, but I use a UnityEvent called GameLoaded that I invoke when the data as been loaded and the game can read it safely. A week ago, that event stopped firing out of nowhere. Then it started working again out of no where. I hadn't change anything, it just happened. It was weird, but since it worked again I didn't worry too much. Now I think DS uses UnityEvents too, so it might be an issue with my events, and DS might not be the cause.
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue System Event not firing

Post by Tony Li »

Hi,

The Dialogue System Events component reacts to "OnConversationStart" and "OnConversationEnd" messages. (And other messages, too, but those are the messages relevant to your question.)

When a conversation starts, the Dialogue System only sends these messages to the Dialogue Manager GameObject and the GameObjects being used as the primary actor and conversant. See Character GameObject Assignments for details.

You can make the primary actor and conversant unambiguous by assigning them to the Dialogue System Trigger's Conversation Actor and Conversation Conversant fields.

To verify that the correct GameObjects are being used for the actor and conversant, temporarily set the Dialogue Manager's Other Settings > Debug Level to Info. This will log a lot of info to the Console window. When a conversation starts, it will log a line in this format:

Dialogue System: Starting conversation 'title' with actor=XXX and conversant=YYY

Verify that XXX and YYY are the GameObjects you intend (i.e., with Dialogue System Events components).
igorsandman
Posts: 35
Joined: Fri Jul 09, 2021 9:50 am

Re: Dialogue System Event not firing

Post by igorsandman »

Hi,
I didn't realize that I had to have character with the DS event script in the actors of the conversation. I added my main character's actor to the conversant field. Now it works.

Question:
What would be the best way to have any script react to onConversationStart and OnConversationEnd? Should I have my own ConversationStart/End events that are fired by the Dialogue Manager?

Thanks!
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue System Event not firing

Post by Tony Li »

Hi,

If the Dialogue System Events component is on the Dialogue Manager GameObject, the two primary participant GameObjects, or their children, it will receive the events.

Similarly, if you have a script with OnConversationStart or OnConversationEnd methods, these methods will be called if they're on those GameObjects.

Otherwise, your own script (on any GameObject anywhere) can hook into the C# events DialogueManager.instance.conversationStarted and conversationEnded. Example:

Code: Select all

void OnEnable()
{
    DialogueManager.instance.conversationStarted += HandleConversationStarted;
}
void OnDisable()
{
    DialogueManager.instance.conversationStarted -= HandleConversationStarted;
}
void HandleConversationStarted(Transform actor)
{
    Debug.Log("Just started conversation: " + DialogueManager.lastConversationStarted);
}
igorsandman
Posts: 35
Joined: Fri Jul 09, 2021 9:50 am

Re: Dialogue System Event not firing

Post by igorsandman »

Thanks for the clear explanations! I will rework my game structure.
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue System Event not firing

Post by Tony Li »

Happy to help!
Post Reply