Exit from Conversation

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
will_888
Posts: 26
Joined: Mon Feb 07, 2022 4:09 am

Exit from Conversation

Post by will_888 »

Hello!
I've made a script in Unity that allows talking with NPCs whenever you walk into a collider area.
When the main character is in the area, you can activate the dialogue by pressing a button.
The script blocks the character animation ad controller input, then in the last sentence, it gets reactivated by interacting through the script.

When the conversation ends, the character can move again. But if I'm using an NPC dialogue, the character will move while the dialogue box is still open, it will close only if I click on Continue. If I use a dialogue option, however, the player can click on the option and the box will disappear allowing the character the move.
How can I create a dialogue block that allows the character movement ONLY after the player closes the finished dialogue?

I would like to have the dialogue behave like in any other role-playing game :P. Can you help me with this or suggest a smarter method? Thank you so much!

Link to the dialogues setup:
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Exit from Conversation

Post by Tony Li »

Hi,

I recommend using a Dialogue System Events component on the player GameObject, as described at 07:00 of the Interaction Tutorial.
will_888
Posts: 26
Joined: Mon Feb 07, 2022 4:09 am

Re: Exit from Conversation

Post by will_888 »

Thank you! Now it works like a charm :)
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Exit from Conversation

Post by Tony Li »

Glad to help!
will_888
Posts: 26
Joined: Mon Feb 07, 2022 4:09 am

Re: Exit from Conversation

Post by will_888 »

Oh, I've encountered another problem.
So, the system you've suggested works, but I need to specify a Conversation Conversant (set to my Main Character prefab) otherwise it won't work.
Problem is that by using a character through different scenes (with DontDestroyOnLoad component), whenever I change scene the Conversation Conversant connection is lost. How can I keep the connection on?

Screenshot for reference (MC_Princess is my main character):

User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Exit from Conversation

Post by Tony Li »

Hi,

Add a Dialogue Actor component to the conversation conversant's GameObject, and set the Actor dropdown to the conversant actor. Then leave the Dialogue System Trigger's Conversation Conversant unassigned.
will_888
Posts: 26
Joined: Mon Feb 07, 2022 4:09 am

Re: Exit from Conversation

Post by will_888 »

Should the Actor be the Main Character, as a best practice?
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Exit from Conversation

Post by Tony Li »

Hi,

Yes. If it's a player - NPC conversation, I usually set the conversation's Actor to the player and the Conversant to the NPC.

You usually set up Dialogue System Triggers on NPCs. If the Dialogue System Trigger's Conversation Conversant field is blank, and if no GameObject has a Dialogue Actor component for the conversant, then the Dialogue System Trigger will use its own GameObject (the NPC GameObject) as the conversation conversant. This matches up nicely if you've set the conversation's Conversant to the NPC. (More info: Character GameObject Assignments)

If you want to be able to use the same "generic" conversation for multiple characters, such as a generic villager conversation for all villager NPCs, you can only specify GameObjects for the primary actor and conversant. So the generic NPC should be the conversation's primary actor or conversant. (And I recommend it be the conversant for the reasons above.)
Post Reply