Events

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
jiendozero
Posts: 4
Joined: Wed Dec 11, 2024 1:58 pm

Events

Post by jiendozero »

Is there a way to have the events like OnConversationEnd fire to the actor/conversant when they're only set in the conversation and not have to also set their transforms in the Dialogue System Trigger?
User avatar
Tony Li
Posts: 23256
Joined: Thu Jul 18, 2013 1:27 pm

Re: Events

Post by Tony Li »

Hi,

If the actor & conversant are the primary actor & conversant in the conversation (i.e., assigned to Conversation Properties > Actor & Conversant dropdowns), then you don't necessarily need to assign their transforms in the Dialogue System Trigger. Please see Character GameObject Assignments.

If you want notification on another participant at the end of the conversation, you can use OnConversationEnd on the Dialogue Manager GameObject. It always receives all OnConversationStart/End messages. Or hook into the C# event DialogueManager.instance.conversationEnded. Example: (works best if characters' GameObjects have DialogueActor components)

Code: Select all

void OnConversationEnd(Transform actor) // Put this on Dialogue Manager
{
    var conversation = DialogueManager.masterDatabase.GetConversation(DialogueManager.lastConversationID);
    var primaryActorIDs = new HashSet<int>() { conversation.ActorID, conversation.ConversantID };
    
    // Identify all non-primary participants:
    var otherActorIDs = new HashSet<int>();
    foreach (var entry in conversation.dialogueEntries)
    {
        var actorID = entry.ActorID;
        if (!primaryActorIDs.Contains(actorID)) otherActorIDs.Add(actorID);
    }
    
    // Send OnConversationEnd messages to them:
    foreach (var actorID in otherActorIDs)
    {
        var actor = DialogueManager.masterDatabase.GetActor(actorID);
        var actorTransform = CharacterInfo.GetRegisteredActorTransform(actor.Name);
        if (actorTransform != null)
        {
            actorTransform.BroadcastMessage(DialogueSystemMessages.OnConversationEnd, DialogueManager.currentActor,  SendMessageOptions.DontRequireReceiver);
        }
    }
}
jiendozero
Posts: 4
Joined: Wed Dec 11, 2024 1:58 pm

Re: Events

Post by jiendozero »

Can you expand on what you mean by not necessarily need to assign the trigger?

This is my setup:
  • Conversation 1 with Player X as Actor assigned in properties
    Game Object 1 with Dialogue Actor assigned as Player X
    Game Object 2 with Dialogue System Trigger that starts Conversation 1
Issue:
After the Conversation 1 is starts or ends. Game Object 1 does not receive any events unless I assign the transform to the trigger in Game Object even though Game Object 1 is the Actor in Conversation 1
User avatar
Tony Li
Posts: 23256
Joined: Thu Jul 18, 2013 1:27 pm

Re: Events

Post by Tony Li »

Hi,

If the Dialogue System Trigger's Actions > Start Conversation > Conversation Actor field is unassigned, and if Game Object 1's Dialogue Actor is set to Player X, then Game Object 1 should receive OnConversationEnd messages. You don't need to do any special scripting in this case.

Please review the link I provided above. It explains how the Dialogue System associates GameObjects with conversation participants.

Also see Logging & Debugging Tips for instructions on how to log which GameObjects are being used as the conversation's actor & conversant.
Post Reply