2 players in dialogue system

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
VillVarh
Posts: 23
Joined: Mon Nov 06, 2023 5:19 am

2 players in dialogue system

Post by VillVarh »

Hello. I have a problem when choosing actor in dialogue. When i start the game i can choose between 2 characters to be the player. They both look different so i can’t just use the same actor in dialogue. What can I do?
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: 2 players in dialogue system

Post by Tony Li »

Hi,

You can assign either actor, or even a completely different actor, to the conversation in the Dialogue Editor.

At runtime, specify the GameObject of the player you want to act as this actor. For more info, see: Character GameObject Assignments
VillVarh
Posts: 23
Joined: Mon Nov 06, 2023 5:19 am

Re: 2 players in dialogue system

Post by VillVarh »

I have a shopkeeper with dialogue system trigger component and usable component. In the "start conversation" field i have set conversation actor and conversant to none. I have 2 players (actors) to chooce between to play with. When I try to activate the conversation with my other player the dialogue actor is still the first player. I don't know how to make it change. Both my players have proximity selector with their own actor transform and they both have dialogue actor component with their own names in the actor field. Still when I try to start conversation with the other player the actor in that conversation is the first player. In the dialogue editor I have set the first player as the actor. :cry:
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: 2 players in dialogue system

Post by Tony Li »

Hi,

Check your conversation in the Dialogue Editor. Select Menu > Conversation Properties. Note the actor that's assigned to the Actor dropdown. Make sure all player nodes in your conversation are assigned to this same actor.

At runtime, when either player interacts with a Dialogue System Trigger whose Conversation Actor is unassigned, the conversation will use that player in place of the actor assigned to the Conversation Properties > Actor dropdown.
VillVarh
Posts: 23
Joined: Mon Nov 06, 2023 5:19 am

Re: 2 players in dialogue system

Post by VillVarh »

Hello It's me again thank you for your help! Now I have a different problem when using UI selector the selector is not working when i click it because selectors buttons onclick has reference to only one player proximityselector.usecurrentselection. This works with that player but it doesn't work with the other player.
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: 2 players in dialogue system

Post by Tony Li »

Hi,

Make sure the NPC's Dialogue System Trigger > Start Conversation > Conversation Actor field is UNassigned. When a specific player's Selector / Proximity Selector "uses" the Dialogue System Trigger and the Conversation Actor field is unassigned, the Dialogue System Trigger will use that player as the conversation actor.

There are a few ways you can get the correct player to use the Dialogue System Trigger:

1. You could assign different Use Key/Buttons to each player.

2. You could make a subclass of Selector / Proximity Selector that checks if the player's CurrentUsable property is set. If so, call its UseCurrentSelection() method.

3. Or you could ignore Selector / Proximity Selector and use your own method to send "OnUse" to the target:

Code: Select all

target.SendMessage("OnUse", this.transform, SendMessageOptions.DontRequireReceiver);
VillVarh
Posts: 23
Joined: Mon Nov 06, 2023 5:19 am

Re: 2 players in dialogue system

Post by VillVarh »

Hello! Ty for your help. I made them different buttons and I destroy the other button based on the character choice. Button problem is solved...almost.

The character selection is happening in another scene. That scene has a Dialogue Manager so when I switch to PlayScene my manager will move to that scene also. My characters are in the PlayScene and they will be SetActive based on what character I chose on the character selection scene. Okay so the button in the PlayScene has onClick event with the player ProximitySelector.UseCurrentSelection but when i click the button nothing happens. On my players Proximity Selector I have enabled touch and It should be working fine but the On selected usable and on deselected usable are empty. Now the problem is that I can't drag the UI trigger button to the On selected usable and on deselected usable because the button doesn't exist in that scene. It comes from the character selection scene with dialogue manager. Do you know how to solve this. :|
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: 2 players in dialogue system

Post by Tony Li »

Hi,

That issue is explained here: How To: Manage Player Controls and Scene Changes.

In the character selection scene, you could save the selection in a DS variable.

In the play scene, add a Dialogue System Trigger set to OnSaveDataApplied. This Dialogue System Trigger will fire when loading a saved game into this scene or when changing into this scene even if you're not loading a saved game. Select Add Action > Set GameObjects Active/Inactive. Assign your player characters. Click on each one, and set the Conditions to check the DS variable.
Post Reply