Page 1 of 2

The Dialogue system launch again with the OnUse trigger

Posted: Sun Jul 26, 2020 11:13 am
by Lyonnais91
Hi,
Thank you for your awesome asset !
I have a problem with the dialogue system and the new input. I can trigger it and It works as intended but if I'm in collision with the gameobject and I close the dialog, the dialog will launch again and I don't know who I can resolve that.

The dialogue trigger is set to OnUse and I launch it when I'm in collision with the gameobject.

I set a variable that will let launch the dialogue if I'm in collision with the gameobject.

Code: Select all

    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.name == "vThirdPersonCamera")
        {
            canLaunchDialogue = true;
        }
    }
If i exit the collision, I set it to false.

Code: Select all

 private void OnCollisionExit(Collision collision)
    {
        if (collision.gameObject.name == "vThirdPersonCamera")
        {
            canLaunchDialogue = false;
        }
    }

Code: Select all

 
    void Update()
    {
        if (joueurGameObject.GetComponent<PlayerInput>().actions["Action1"].ReadValue<float>() == 1 && canLaunchDialogue == true && dialogueManager.GetComponent<PixelCrushers.DialogueSystem.DialogueSystemController>().IsConversationActive == false) 
// If the user press Enter with the keyboard or A with a joystick, and the gameobject is in collision, and a dialogue is not launched, the dialog will launch
        {
            this.gameObject.GetComponent<PixelCrushers.DialogueSystem.DialogueSystemTrigger>().OnUse();
        }
    }
The key to launch dialog is the same as making a choice, I think it launch the dialog in the same time as It close the dialog so I think that the problem.

Re: The Dialogue system launch again with the OnUse trigger

Posted: Sun Jul 26, 2020 11:34 am
by Tony Li
Hi,

It looks like you're using Invector. I recommend using Invector's interaction system to trigger conversation. This will handle the issue and also work more like all other Invector integration. See the "Dialogue System Invector Locomotion" example scene. The NPC is set up like this:

dsInvectorInteraction.png
dsInvectorInteraction.png (53.99 KiB) Viewed 1102 times

Re: The Dialogue system launch again with the OnUse trigger

Posted: Sun Jul 26, 2020 12:01 pm
by Lyonnais91
Thank you for your answer !

I have only the lite version of invector so I don't have the trigger generic action component and I have only one scene as an exemple.

Is there anything I can do to trigger a dialogue with a key with a proper exit ?

Edit : Yes, If I change the button to launch the dialogue, it works but if it's the same button like I want, it doesn't quit the dialogue and launch the conversation again.

Re: The Dialogue system launch again with the OnUse trigger

Posted: Sun Jul 26, 2020 1:39 pm
by Tony Li
Hi,

If your script is on the Dialogue Manager GameObject or player GameObject, add a Dialogue System Events components. Configure the OnConversationStart() event to disable the script. Configure OnConversationEnd() to re-enable it.

Re: The Dialogue system launch again with the OnUse trigger

Posted: Mon Jul 27, 2020 12:12 pm
by Lyonnais91
Hi,
Sorry but that doesn't work, it launch again.

It should not launch again, one of my condition to trigger the dialog system is

Code: Select all

"dialogueManager.GetComponent<PixelCrushers.DialogueSystem.DialogueSystemController>().IsConversationActive == false"
So I think it launch a little after the conversation has ended but I don't know what I can do.

Edit : Yes, it launch again in the same second that the conversation end but after.

Re: The Dialogue system launch again with the OnUse trigger

Posted: Mon Jul 27, 2020 1:20 pm
by Tony Li
Change the Dialogue System Events component to call two methods on your script instead of disabling and re-enabling the script:

OnConversationStart()

Code: Select all

public void HandleConversationStart()
{
    enabled = false;
}
OnConversationEnd()

Code: Select all

public void HandleConversationEnd()
{
    // Wait one frame to allow input to clear:
    StartCoroutine(EnableAfterOneFrame());    
}
IEnumerator EnableAfterOneFrame()
{
    yield return null;
    enabled = true;
}

Re: The Dialogue system launch again with the OnUse trigger

Posted: Mon Jul 27, 2020 1:34 pm
by Lyonnais91
Wow, It was not working and then I changed the coroutine to wait one second and now It's working and the conversation don't repeat.

Thank you so much for taking the time to help !

Have a nice day ! ;)

Re: The Dialogue system launch again with the OnUse trigger

Posted: Mon Jul 27, 2020 1:36 pm
by Tony Li
Glad to help!

Re: The Dialogue system launch again with the OnUse trigger

Posted: Tue Jul 28, 2020 2:04 pm
by Lyonnais91
Hi Tony !
With the same code, I have a warning "Another conversation is already active. Not Starting." in the start of the conversation in the same second.
I tried to make a coroutine to wait a little but that doesn't work.

Re: The Dialogue system launch again with the OnUse trigger

Posted: Tue Jul 28, 2020 2:37 pm
by Tony Li
Hi,

Try to identify what is trying to start the second conversation. If you click on the warning in the Console window, the bottom part of the Console window will show the stack trace. This will tell you what tried to start the conversation.

For example, I configured a Dialogue System Trigger to use OnEnable in a test scene. I played the scene, which started the conversation. Then I disabled and re-enabled the Dialogue System Trigger, which made it try to start another conversation. If I click on the warning, it shows this stack trace:

stackTrace.png
stackTrace.png (69.89 KiB) Viewed 1034 times

In your case, you may see that the bottom line of the stack trace is some line in one of your scripts.