Page 1 of 1

Runtime database not showing choices

Posted: Fri May 23, 2025 9:53 am
by WarriorDogDev
I'm planning on having dynamic choices that will redirect to other dialogues (each choice will be an NPC in a location that the player can interact with). I've created a runtime database with dialogue entries with the player as the actor, but when I execute the function, the dialogue only shows the last dialogue entry as normal text, not as a choice.

When I try to play the runtime dialogue in the master dialogue view, only the first choice is shown, but as a choice and not as a normal text (the first dialogue entry is blue and the second is gray).And then, when I click on the second dialogue entry in the editor (it changes from gray to blue) and try to play the dialogue again, both choices are displayed.
Result example.png
Result example.png (98.89 KiB) Viewed 8275 times
Editor view 1.png
Editor view 1.png (27.65 KiB) Viewed 8275 times
After clicking in the second dialogue entry
Editor view 2.png
Editor view 2.png (27.53 KiB) Viewed 8275 times

Code: Select all

  public void GenerateActorSelection()
  {
    var database = ScriptableObject.CreateInstance<DialogueDatabase>();
    var template = Template.FromDefault();

    // Create conversation
    //int conversationId = template.GetNextConversationID(database);
    int conversationId = 1000;
    var conversationTitle = "Choices";
    var conversation = template.CreateConversation(conversationId, conversationTitle);
    conversation.ActorID = 1;
    database.conversations.Add(conversation);

    // START node
    var startNode = template.CreateDialogueEntry(0, conversation.id, "START");
    startNode.Sequence = "None()";
    conversation.dialogueEntries.Add(startNode);

    // Dialogue nodes
    var choice1 = template.CreateDialogueEntry(1, conversation.id, string.Empty);
    choice1.ActorID = 1;
    conversation.ConversantID = 1;
    choice1.DialogueText = "Choice 1";
    conversation.dialogueEntries.Add(choice1);

    // Dialogue nodes
    var choice2 = template.CreateDialogueEntry(2, conversation.id, string.Empty);
    choice1.ActorID = 1;
    conversation.ConversantID = 1;
    choice2.DialogueText = "Choice 2";
    conversation.dialogueEntries.Add(choice2);

    // Link from START to Choice 1
    var link = new Link(conversation.id, startNode.id, conversation.id, choice1.id);
    startNode.outgoingLinks.Add(link);

    // Link from START to Choice 2
    var link2 = new Link(conversation.id, startNode.id, conversation.id, choice2.id);
    startNode.outgoingLinks.Add(link2);

    DialogueManager.AddDatabase(database);
    DialogueManager.StartConversation("Choices");
  }

Re: Runtime database not showing choices

Posted: Fri May 23, 2025 10:07 am
by Tony Li
Hi,

I think there's a typo in this code:

Code: Select all

// Dialogue nodes
var choice2 = template.CreateDialogueEntry(2, conversation.id, string.Empty);
choice1.ActorID = 1;
conversation.ConversantID = 1;
choice2.DialogueText = "Choice 2";
conversation.dialogueEntries.Add(choice2);
The second line there should probably be:

Code: Select all

choice2.ActorID = 1;

Re: Runtime database not showing choices

Posted: Fri May 23, 2025 11:05 am
by WarriorDogDev
Man, I can't believe I went through all this trouble because of this :lol:
Thanks a lot! It's working like it should now.

Re: Runtime database not showing choices

Posted: Fri May 23, 2025 11:50 am
by Tony Li
Glad to help!