The Dialogue system launch again with the OnUse trigger

Announcements, support questions, and discussion for the Dialogue System.
Lyonnais91
Posts: 8
Joined: Sun Jul 26, 2020 10:45 am

The Dialogue system launch again with the OnUse trigger

Post 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.
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: The Dialogue system launch again with the OnUse trigger

Post 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 1098 times
Lyonnais91
Posts: 8
Joined: Sun Jul 26, 2020 10:45 am

Re: The Dialogue system launch again with the OnUse trigger

Post 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.
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: The Dialogue system launch again with the OnUse trigger

Post 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.
Lyonnais91
Posts: 8
Joined: Sun Jul 26, 2020 10:45 am

Re: The Dialogue system launch again with the OnUse trigger

Post 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.
Attachments
Dialogue system console.PNG
Dialogue system console.PNG (92.59 KiB) Viewed 1075 times
Dialogue system.PNG
Dialogue system.PNG (74.04 KiB) Viewed 1078 times
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: The Dialogue system launch again with the OnUse trigger

Post 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;
}
Lyonnais91
Posts: 8
Joined: Sun Jul 26, 2020 10:45 am

Re: The Dialogue system launch again with the OnUse trigger

Post 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 ! ;)
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: The Dialogue system launch again with the OnUse trigger

Post by Tony Li »

Glad to help!
Lyonnais91
Posts: 8
Joined: Sun Jul 26, 2020 10:45 am

Re: The Dialogue system launch again with the OnUse trigger

Post 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.
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: The Dialogue system launch again with the OnUse trigger

Post 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 1030 times

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