I am creating a rogue-lite that has multiple selectable characters. I am trying to incorporate this into the dialogue system. I've read various posts on the forums about various ways this has been handled, but I'm wondering if there is a best method for doing this that is intended or recommended. Each method I've identified has both advantages and drawbacks.
I have different conversations and conversation options for different characters, and I am also playing audio for voices for each different playable character which eliminates some of the simpler options such as just changing the name displayed for the actor within the conversation.
The main two methods that I have identified that work for this context is to have either a generic "Player" actor, or to have specific actors for each character, set the "IsPlayer" variable on character selection, and then manage it after that.
The main advantages to the first option (generic player actor) is that I can have conversations that start out in a generic manner and can then branch off based upon which character is selected via changing variables within the Player actor and then using conditions to check which character is the one being played. The main disadvantages I can see in this situation is that I need to do lots of conditions all over and that managing the audio clips played for different characters will get complex and can be error prone. I would also have to figure out a different method for playing audio clips since my current method isn't conditional, so using the same node to play different audio clips based upon the selected character would be something I would have to tackle for the 'generic' response nodes.
The main advantages for the second option (Changing "IsPlayer" variable at runtime) is that I can then just split off into different conversations depending upon which actor is the player. I wouldn't have to do any condition checks in this method to determine which actor is the player after switching to the specific conversation for that player. Everything would be less cluttered but much more spread out. This is also the main disadvantage because that would essentially eliminate the generic conversation sections from the other option. I would have to have the same node path in different conversations to have the same interaction, and to change these identical parts I would have to go through each conversation to update them.
I would really appreciate advice on which option is the better one, or if there is a third option that is best which I haven't identified yet. I am hesitant to pick one of the two options because I suspect that there are disadvantages that may reveal themselves to either option once I start to build it out to scale, and I am trying to avoid redoing work the best I can.
Thanks for any suggestions or help anyone may give!
Multiple playable characters methods
Re: Multiple playable characters methods
Hi,
Create a generic Player actor and specific player character actors -- for example, I'll use Ann, Bob, and Cal here. Tick the Is Player checkbox on all of them.
Write your conversations using the generic Player actor. Set the conversation's Actor dropdown to the Player actor.
Create GameObjects for Ann, Bob, and Cal. Add a Dialogue Actor to each, and set the Actor dropdown to the corresponding actor.
When you start a conversation, you can pass Ann, Bob, or Cal as the player GameObject. To do this, assign Ann, Bob, or Cal to the Dialogue System Trigger's Conversation Actor field, or if you're using C# pass it to DialogueManager.StartConversation(). Any lines that are assigned to Player will instead be spoken by the GameObject you pass to it. More info: Character GameObject Assignments
When the conversation starts, the Dialogue System will set Variable["Actor"] to the name of the actor you passed to the Dialogue System Trigger or DialogueManager.StartConversation(). (More info: Special Variables.) Technically, it will set Variable["Actor"] to the actor's display name, and it will set Variable["ActorIndex"] to a sanitized version of the actor's Name field.
You can check either variable in Conditions:
You can use Variable["Actor"] in Dialogue Text, too:
For multiple player characters, you could name your audio files like:
Create a generic Player actor and specific player character actors -- for example, I'll use Ann, Bob, and Cal here. Tick the Is Player checkbox on all of them.
Write your conversations using the generic Player actor. Set the conversation's Actor dropdown to the Player actor.
Create GameObjects for Ann, Bob, and Cal. Add a Dialogue Actor to each, and set the Actor dropdown to the corresponding actor.
When you start a conversation, you can pass Ann, Bob, or Cal as the player GameObject. To do this, assign Ann, Bob, or Cal to the Dialogue System Trigger's Conversation Actor field, or if you're using C# pass it to DialogueManager.StartConversation(). Any lines that are assigned to Player will instead be spoken by the GameObject you pass to it. More info: Character GameObject Assignments
When the conversation starts, the Dialogue System will set Variable["Actor"] to the name of the actor you passed to the Dialogue System Trigger or DialogueManager.StartConversation(). (More info: Special Variables.) Technically, it will set Variable["Actor"] to the actor's display name, and it will set Variable["ActorIndex"] to a sanitized version of the actor's Name field.
You can check either variable in Conditions:
- Dialogue Text: "My name is Bob."
- Conditions: Variable["ActorIndex"] == "Bob"
You can use Variable["Actor"] in Dialogue Text, too:
- Dialogue Text: "My name is [var=Actor]."
- Sequence: AudioWait(entrytag)
- Sequence: AudioWait(Player_7_42)
For multiple player characters, you could name your audio files like:
- Player_7_42_Ann
- Player_7_42_Bob
- Player_7_42_Cal
- Sequence: AudioWait(entrytag_[var=ActorIndex])
- Sequence: AudioWait(Player_7_42_Ann)
Re: Multiple playable characters methods
That is incredibly helpful! Thanks Tony! It's very impressive to see how polymorphic the Dialogue System is.
I'm using FMOD for my audio so I'll try to use the FMODWait() sequencer command I've found on the forums in combination with your suggestion for handling dialogue audio.
Your help just made this the best unity asset I've invested in by a significant margin.
I'm using FMOD for my audio so I'll try to use the FMODWait() sequencer command I've found on the forums in combination with your suggestion for handling dialogue audio.
Your help just made this the best unity asset I've invested in by a significant margin.
Re: Multiple playable characters methods
Glad to help! You can absolutely use entrytags with FMODWait(). Just incorporate the entrytag into the FMOD event name.