Problem with different character assigned as conversant.

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
hellwalker
Posts: 112
Joined: Tue Jan 19, 2016 11:37 pm

Problem with different character assigned as conversant.

Post by hellwalker »

Hi,

I'm running into a bit of a trouble with how DS assigns gameobjects to conversant.

I have a situation like this:

I'm using Adventure Creator and Dialogue System. I have two players in the game, let's call them Larry & Barry, so two IsPlayer tagged NPC-s in DS DB and Two runtime created PC's in AC.

I'm using DS actions in AC cutscenes to launch the conversations. And what happens is whoever my AC player is at the moment becomes target for first player to talk in DS conversation, and he will speak lines of both players. So for example:

Larry: Hi, I'm Larry!
Barry: and I'm Barry!

And my current player is Barry he will speak both lines.

I can fix some of these, by assigning conversant in AC cut-scene action that launches conversation. But that's problematic when characters are spawned at runtime.


So I'm a bit confused on how to approach this. Is there a way to disable context sensitive character assignment by default, and enable it in specific cases? For the most part I need lines to be spoken by same characters that are assigned in DS dialogue nodes.

Thanks.
User avatar
Tony Li
Posts: 22655
Joined: Thu Jul 18, 2013 1:27 pm

Re: Problem with different character assigned as conversant.

Post by Tony Li »

Hi,

In your dialogue database, can you create IsPlayer=false versions of Barry and Larry, and assign them to those nodes? For nodes that are player responses, create and assign a general-purpose Player actor with IsPlayer=true. I'm at Unite right now and unable to test this, but I think it should work. If it doesn't, I'll put together the steps for a solution as soon as I get back.
hellwalker
Posts: 112
Joined: Tue Jan 19, 2016 11:37 pm

Re: Problem with different character assigned as conversant.

Post by hellwalker »

Thanks ! I'll try that.
No rush, enjoy the Unite! ^^
User avatar
Tony Li
Posts: 22655
Joined: Thu Jul 18, 2013 1:27 pm

Re: Problem with different character assigned as conversant.

Post by Tony Li »

Okay, I'm back! :-) Sorry about the delay in replying.

Here's how I set it up. In the dialogue database's Actors section, I created three actors:
  • Player: IsPlayer=true. Used for response menu nodes.
  • Barry: IsPlayer=false. Used for nodes that should always be spoken by Barry.
  • Larry: IsPlayer=false. Used for nodes that should always be spoken by Larry.
If you've also defined additional Barry and Larry actors whose IsPlayer=true, you can name these IsPlayer=false actors "Barry NPC" and "Larry NPC". Then tick Use Display Name, and set the Display Names to "Barry" and "Larry". This way they'll appear the same to the user.

In nodes assigned to Player, Menu Text and Dialogue Text can use the tag "[var=Actor]" to incorporate the current player's name. For example:
  • Player: "Hi! I'm [var=Actor]."
If you want the other actor to pipe up, use Conditions:
  • Player: "Hi! I'm [var=Actor]."
    • Barry: "And I'm Barry!" { Conditions: Variable["Actor"]=="Larry" }
    • Larry: "And I'm Larry!" { Conditions: Variable["Actor"]=="Barry" }
After is active player introduces himself, the Conditions will dictate which of the follow-up lines to show.

(I'm using outline form above to keep this reply short, but if you'd like to see a screenshot of the nodes in the node editor just let me know.)

In my test scene, when Barry is the current player, Larry is represented by an NPC named "LarryNPC". Since I don't want his name to show up as "LarryNPC" in conversations, I added an Override Actor Name component to LarryNPC and set the override name to "Larry".
hellwalker
Posts: 112
Joined: Tue Jan 19, 2016 11:37 pm

Re: Problem with different character assigned as conversant.

Post by hellwalker »

Thank you! I missed the notification, so I did not reply before.

This works great, I just need one more edit I think to make this work for me.
Is there a way to access conversations Actor field from inside OnConversationLine()? Like when you start the conversation through trigger or AC, you can specify actor and conversant, is there a way to access this field?

Or maybe there is better solution. Basically what I have is I have a custom speech bubble Subtitle UI that positions itself over current speaker. I'm using subtitle.speakerInfo.transform to find the speaker, this worked nicely with both NPC being Larry and Barry as I always had gameobjects in the scene with names Larry and Barry, and DS matched conversant actor to them.

But with player this is not the case, as there is no Player gameobject in the scene. So I was thinking of replacing player first with Actor Field transform in cases I set specific NPC (Larry or Barry) to be Actor and thus speaking for them, or if it was blank I would use AC's current Player.

So I'd have code like this in void OnConversationLine(Subtitle subtitle)

Code: Select all

  if (subtitle.speakerInfo.Name.Equals("Player"))
  {
                if (ActorField.transform != null)
                    Conversant  = ActorField.transform;
                else
                    Conversant = AC.KickStarter.player.transform;
   }
   else
           Conversant = subtitle.speakerInfo.transform;
User avatar
Tony Li
Posts: 22655
Joined: Thu Jul 18, 2013 1:27 pm

Re: Problem with different character assigned as conversant.

Post by Tony Li »

Hi,

You can check speakerInfo.nameInDatabase to get the name of the speaker as defined in your dialogue database. Does that help?

If you want to get the entire Actor record, you can use this code:

Code: Select all

var actor = DialogueManager.MasterDatabase.GetActor(subtitle.speakerInfo.id);
hellwalker
Posts: 112
Joined: Tue Jan 19, 2016 11:37 pm

Re: Problem with different character assigned as conversant.

Post by hellwalker »

Hi, no I meant to get the actor assigned to conversation.
Image
This field.
User avatar
Tony Li
Posts: 22655
Joined: Thu Jul 18, 2013 1:27 pm

Re: Problem with different character assigned as conversant.

Post by Tony Li »

Hi,

It will try to match the actor transform's GameObject name to an actor in the dialogue database. For example, if the character who triggers the conversation is Barry (and if the GameObject is named "Barry"), it will match it to the actor named Barry in the dialogue database. speakerInfo.nameInDatabase will be "Barry", and speakerInfo.id will be the ID of the actor named Barry. If the actor GameObject isn't named Barry -- for example, if it's named something like Barry_PC(Clone) -- add an Override Actor Name component to it, and set the Override Name to Barry.
Post Reply