Single OnUse Message appears to trigger twice.

Announcements, support questions, and discussion for the Dialogue System.
User avatar
rykaan
Posts: 75
Joined: Tue Feb 11, 2020 6:22 am

Single OnUse Message appears to trigger twice.

Post by rykaan »

Hi Tony,

I've been changing the Dialogue Triggers from my janky mess, over to a system that much more resembles what you intended with this Plugin and I've run into an odd issue. My characters are sending a single OnUse message to Monsters/Each other but everything seems to be triggered twice. The second trigger causes the character that sent the message to trigger the same conversation again but say a blank message (which is reported in the console window). I have some images to show what I think is happening:

This is the console after triggering a Monster using 'Brother' (one of my characters).
Double Trigger conversation.jpg
Double Trigger conversation.jpg (301.38 KiB) Viewed 1447 times

Here is the information from the two console entries that are showing Brother saying something:
Triggered Dialogue Console Info.jpg
Triggered Dialogue Console Info.jpg (424.21 KiB) Viewed 1447 times
It looks like the single OnUse command is finding two different routes to trigger the same conversation. I wouldn't have noticed this for a while, but when my other character has a conversation with a monster the game remains paused once the conversation ends. I am thinking because the Pause Game During Conversation isn't unpausing with a second bugged conversation happening.

Do you have any thoughts why this may be happening and what I can do to prevent it? This appears to happen when Sending OnUse messages to anything, my save point/monsters/Item Box/etc, even when there's no conversation to trigger it will cause various things to happen an additional time (most of the time not causing a noticeable issue but it's not ideal). Let me know if you need any further info to look into it.

Cheers,
Rob
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Single OnUse Message appears to trigger twice.

Post by Tony Li »

Can you post a Dialogue Editor screenshot of the first few nodes of the conversation?

As a test, does the same issue occur if the Dialogue System Trigger is set to OnStart instead of OnUse?

Does your player have two Selectors / ProximitySelectors / whatever custom script you're using to send OnUse? If so, they could both be sending OnUse.

However, it looks like the Dialogue System Trigger is only receiving one OnUse. See the 5th line in your Console screenshot.

I suspect the red-circled log entry (Brother says '') is just the usual output that's shown for the <START> node. Make sure you haven't changed anything on the <START> node. In particular, the Sequence should still be 'None()'.
User avatar
rykaan
Posts: 75
Joined: Tue Feb 11, 2020 6:22 am

Re: Single OnUse Message appears to trigger twice.

Post by rykaan »

Thanks for the response Tony.

I agree the OnUse appears to only send once. But it looks like it finds two ways to trigger the conversation from that one use. Here's a screenshot of the conversation triggering from OnStart:
OnStart conversation info.jpg
OnStart conversation info.jpg (380.77 KiB) Viewed 1440 times
Despite the conversation correctly choosing the dialogue with Sister (The variable deciding which character interacting defaults to her) it still managed to cause my other character to Say something.

Here's a screenshot of it happening else where:
Item box and save point dialogue.jpg
Item box and save point dialogue.jpg (242.14 KiB) Viewed 1440 times
The top example (Item box opening) doesn't have a conversation to trigger but triggers the same bit of code twice. The bottom one (interacting with a save point) does have a confirmation conversation but Brother says a blank line in the console there to. Each time a single OnUse Message is sent, but I get duplicated results back from different interactables.

I'll add my Interaction code below in case it's causing the issue:

Code: Select all

public void SisterInteract()
    {
        DialogueLua.SetVariable("Brother Interact", false);
        Debug.Log("Sister Interact!");
        hit = (Physics2D.Raycast(transform.position - new Vector3(0, 0.3f, 0),
                CharacterFacingMethods.DirectionFromAngle(0f, npcBase.facing), 1f, layerMask.value));
        if (hit != false)
        {
            hit.collider.SendMessage("OnUse", transform);
        }
    }    
The script on my other character (Brother) is very similar but has an if statement to play an animation if holding a knife. I Imagine there must be some issue with how the Object is receiving and processing the OnUse message, but I'm using the Dialogue System Trigger in each case so I don't know where the duplicated trigger comes from.
Any ideas?

Cheers,
Rob
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Single OnUse Message appears to trigger twice.

Post by Tony Li »

Hi Rob,

Look at the Brother console log, you circled two identical-looking sections in green. This is what I think is going on:

brother.png
brother.png (610.79 KiB) Viewed 1438 times

Does the Dialogue System Trigger's Conditions section specify any conditions?

Does it use Play Sequence action to play FaceTarget()?

Is the Start Conversation action's Skip If No Valid Entries checkbox ticked?

Does the blank text (Brother says '') result in any unwanted visible effect when you play?
User avatar
rykaan
Posts: 75
Joined: Tue Feb 11, 2020 6:22 am

Re: Single OnUse Message appears to trigger twice.

Post by rykaan »

Hi Tony,

So the repeated lines aren't multiple triggers, that's good to know, that reduces the number of issues down to just the conversation not unpausing correctly. To answer your questions:

There are two conditions on that conversation triggering by Brother. One is that the Monster is unaware of the player character and the other is that the player isn't holding a knife (If he is holding a knife it triggers a different Trigger).

The Trigger does cause a sequence to play that turns the Monster towards the player and that works correctly.

The 'skip if no valid entries' is ticked yes.

I don't see any artifact from the 'Brother says' line of dialogue.

So following on from that, the failed unpause issue I am having isn't as a result of some double triggered conversation. When that blue side of the conversation is triggered, if the 'Variable["Brother_Interact"] == false' condition is in place then the conversation doesn't unpause at the end:
trigger pause glitch.jpg
trigger pause glitch.jpg (284.44 KiB) Viewed 1430 times
What I can do is separate these two sides of the conversation out into two conversations and work just from tags. I'm just curious what I've messed up regarding setting up this condition. When the player presses Sister's interact button the variable is set to false and when Brother's interact button is pressed it's set to true. I figured doing this would half the size of the interaction conversations in the database and make organisation easier. I just can't figure where I've messed it up :S. I'll give it another look but otherwise I'll just split the conversations up.

Cheers,
Rob
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Single OnUse Message appears to trigger twice.

Post by Tony Li »

Hi Rob,

If you keep the Dialogue Editor window open on the conversation while you're playing, does it show the current node in green?

If so, then if you're interacting as Brother, does it get all the way to the last node? ("[Sister] Remember to equip...")

What happens when it gets to that node?

What is supposed to happen that isn't happening?
User avatar
rykaan
Posts: 75
Joined: Tue Feb 11, 2020 6:22 am

Re: Single OnUse Message appears to trigger twice.

Post by rykaan »

Hi Tony,

The Dialogue editor doesn't seem to highlight in green for me during conversations. I checked on a few different conversations, is that an option I have to turn on?

I believe I've worked out the issue however. So the setup I was using was to have a separate Dialogue trigger for Brother and Sister (my two characters) on the monster. The triggers have different conditions so the player would see the right part of the conversation. The problem of the game not unpausing after the conversation ended was caused by using the same conversation on both triggers. SO the conversation 'Greeting' was used in both these cases and a condition would change the path of the conversation to read correctly.

I confused myself further and came to the wrong conclusion when I copied the conversation and changed a few parameters to try to figure out the issue. After removing the variable 'Variable["Brother_Interact"] == false' the issue went away so I assumed that was the problem. But actually the issue was fixed by simply having a differently named conversation triggering.

I'll split the Brother and Sister conversations with each monster/character/etc and just use accepted tags to differentiate between them as I should have from the start. Here's hoping I haven't missed something again. At this stage all the conversations etc are placeholder anyway so this is all helping me figure out the workflow for later in the project.

Cheers again,
Rob
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Single OnUse Message appears to trigger twice.

Post by Tony Li »

Hi Rob,

I'm sure with more investigating we could get the other way to work, but it's probably better in the long run to split the conversations anyway to keep them more manageable in the editor.

The Dialogue Editor should automatically highlight the active node of the active conversation in green. But you must have the editor open on the active conversation.

For a test, you can play DemoScene1, open the Dialogue Editor and inspect the "Private Hart" conversation, and then interact with the NPC (Private Hart). It should show the current dialogue entry node in green.
User avatar
rykaan
Posts: 75
Joined: Tue Feb 11, 2020 6:22 am

Re: Single OnUse Message appears to trigger twice.

Post by rykaan »

Hi Tony,

So I checked the demo scene, (I triggered it onStart since I've changed the control method which broke the demo character movement) and I see the green highlight. But I don't see it on my own conversations in my scenes.
No green conversation highlight.jpg
No green conversation highlight.jpg (273.41 KiB) Viewed 1414 times
[Forgive the huge number of placeholders in this image]

I tried triggering a conversation using onStart but that also didn't show the green highlight. I must have broken it somewhere along the line but I'm not sure where.

Cheers,
Rob
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Single OnUse Message appears to trigger twice.

Post by Tony Li »

Hi Rob,

At runtime, the Dialogue Editor checks DialogueManager.currentConversationState. The conversation state has a reference to a dialogue entry. Each dialogue entry has a conversation ID (which should match its conversation's ID) and a unique entry ID. If a node with a matching conversation ID and entry ID is visible, it's shown in green.

Is it possible that the entry's internal conversation ID got broken somehow? Have you manually changed any internal ID numbers?

Are you looking at the correct dialogue database? Maybe the scene is using a duplicate copy of the database in which the IDs are different?
Post Reply