Page 1 of 1

Changing panels from dialogue entry

Posted: Sun Mar 12, 2023 5:42 am
by Dralks
Hi Tony!

I need some advice, I created a sequence that on every entry sends the actor location and the actor id over, so from the code I can set up the location (Room, office, beach or whatever) and which panel to use based on your VN style example (as many characters are visible at the same time), the second gives me problems because I think that at dialogue entry level it is too late to set up a panel, if I set up every actor panel in advance (they do not exist as gameobjects) it works fine, which I quickly tested with:

Code: Select all

private void CharacterPanel(int actorId)
    {
        foreach (var actor in DialogueManager.MasterDatabase.actors)
        {
            DialogueManager.PlaySequence($"SetPanel({actor.Name},{panelNumber});");
            panelNumber++;
        }
    }
but if I try to use the dialogue entry actor to set up the panel they all use panel 0, I presume that the conversation already started at this point and the panel has been decided so it is too late to change it.

How can my sequence decide which panel this specific text is going to use? Panels may change during the same conversation that is why I'm setting the panel individually at dialogue entry level.

this is my sequence sending location id and actor id (I have some code adding that sequence to each entry)
Image

Re: Changing panels from dialogue entry

Posted: Sun Mar 12, 2023 9:50 am
by Tony Li
Hi,

A dialogue entry's Sequence plays immediately after the entry has been shown in a subtitle panel.

However, the entry's Script field, and any scripts with OnConversationLine methods, run before showing the entry in a subtitle panel. If you want to use the Script field, you can register a C# method with Lua that calls DialogueManager.standardDialogueUI.SetActorSubtitlePanelNumber() [sets the panel used by a DialogueActor] or OverrideActorPanel() [sets the panel used by an Actor in your database]. Or, if you want to use an OnConversationLine method, you could add a SetPanel() sequencer command to the subtitle's sequence:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    // Line below just shows format; doesn't use correct actor name(s) or panel number(s).
    subtitle.sequence = $"SetPanel(actorName, panelNumber); {subtitle.sequence}";
}

Re: Changing panels from dialogue entry

Posted: Sun Mar 12, 2023 10:36 am
by Dralks
You are a costumer service god Tony, OnConversationLine is what I needed and it is 1000% better than using the sequence for my scenario as I can access everything from there directly.

Thanks!

Re: Changing panels from dialogue entry

Posted: Sun Mar 12, 2023 11:38 am
by Tony Li
Happy to help!

Re: Changing panels from dialogue entry

Posted: Sun Mar 12, 2023 6:40 pm
by Dralks
Sorry for asking so much Tony, it has been a full dialogue weekend.

I got stuck for a some hours with this:

I'm using a simple set panel code to change my actors panels, this worked perfectly until an actor player started using, that actor's text goes very fast an the next box stays empty:

Code: Select all

    // Actor can appear on diferent locations of the scene, this decides which panel
    private void CharacterLocation(int actorId)
    {
        var actor = DialogueManager.MasterDatabase.actors.FirstOrDefault(x => x.id == actorId);

        if (string.IsNullOrEmpty(actorUsingFirstPanel) || actorUsingFirstPanel == actor.Name)
        {
            actorUsingFirstPanel = actor.Name;
            DialogueManager.PlaySequence($"SetPanel({actor.Name},0)");
        }
        else
        {
            DialogueManager.PlaySequence($"SetPanel({actor.Name},2)");
        }
    } 
I solved that by adding "@{{end}}"

Code: Select all

    // Actor can appear on diferent locations of the scene, this decides which panel
    private void CharacterLocation(int actorId)
    {
        var actor = DialogueManager.MasterDatabase.actors.FirstOrDefault(x => x.id == actorId);

        if (string.IsNullOrEmpty(actorUsingFirstPanel) || actorUsingFirstPanel == actor.Name)
        {
            actorUsingFirstPanel = actor.Name;
            DialogueManager.PlaySequence($"SetPanel({actor.Name},0);" + "@{{end}};");
        }
        else
        {
            DialogueManager.PlaySequence($"SetPanel({actor.Name},2);" + "@{{end}};");
        }
    } 
but then the panel is not set at all for any actor, they all use the first one available, and no amount of playing around seems to solve that, tried different combinations, not sure what I'm missing, I would like the first code to do exactly the same no matter if the actor isPlayer or NPC

Re: Changing panels from dialogue entry

Posted: Sun Mar 12, 2023 8:39 pm
by Tony Li
Hi,

This may not address all of the issues, but there's a typo in the two DialogueManager.PlaySequence() lines. Instead of this:

Code: Select all

DialogueManager.PlaySequence($"SetPanel({actor.Name},0);" + "@{{end}};");
Try this: (remove a semicolon)

Code: Select all

DialogueManager.PlaySequence($"SetPanel({actor.Name},0)" + "@{{end}};");
or this:

Code: Select all

DialogueManager.PlaySequence($"SetPanel({actor.Name},0){{{{end}}}};");

Re: Changing panels from dialogue entry

Posted: Mon Mar 13, 2023 4:08 am
by Dralks
yes sorry, that was just one of my last attempts trying to see what is wrong, originally I had

Code: Select all

DialogueManager.PlaySequence($"SetPanel({actor.Name},0)" + "@{{end}};");
Edit: I saw the issue, I believe it is because I have only 1 PC panel but 4 NPC panels, if I multiply these PC panels I seem to be able to assign them to different player actors, but I can't see what makes a PC panel "isPlayer" only, I compared both and the same settings are present, is it the (PC) in the name? Is there any way to make any actor use any panel no matter if "isPlayer" or not?

Image

Re: Changing panels from dialogue entry

Posted: Mon Mar 13, 2023 8:52 am
by Tony Li
Hi,

Any actor can use any subtitle panel, regardless of whether the actor's IsPlayer checkbox is ticked or not. You can assign panels to the StandardDialogueUI component's Default NPC Subtitle Panel and Default PC Subtitle Panel, in which case an actor will use one of these default panels if no panel is specified for the actor.

Is it possible that a DialogueActor component on a player actor's GameObject is overriding the panel number?

Or maybe are you seeing the player portrait appear in the response menu panel's PC Image?

Re: Changing panels from dialogue entry

Posted: Mon Mar 13, 2023 3:08 pm
by Dralks
I have no gameobjects with Actors, the panel is being set in code only and the player portrait changes to the assigned panel correctly if it is one of those PC panels, but after double checking both panels they look exactly the same, same settings everywhere as far as I can tell, but it is fine, I went around the issue by duplicating the panels, I have 4 PC panels and for non-PC panels and just use them based on the isPlayer flag, that works fine, I will take another look this week and let you know if I find out why