About Dialogue Actor component

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: About Dialogue Actor component

Post by Tony Li »

Thank you for the reminder. I looked into it. I'm afraid it might break other developers' existing projects, so I came up with an alternate solution. On March 7, I used the example of a Grumpy Man and Grumpy Woman. Say your conversation has a third participant named "Extra NPC".

If you want Grumpy Man to be the Extra NPC, call CharacterInfo.RegisterActorTransform("Extra NPC", grumpyMan.transform) before starting the conversation. If you want Grumpy Woman to be the Extra NPC, call CharacterInfo.RegisterActorTransform("Extra NPC", grumpyWoman.transform) before starting the conversation.
CHOPJZL
Posts: 97
Joined: Wed Sep 02, 2020 10:05 pm

Re: About Dialogue Actor component

Post by CHOPJZL »

Is it workable when "Extra NPC" exists in multiple running conversations?
CHOPJZL
Posts: 97
Joined: Wed Sep 02, 2020 10:05 pm

Re: About Dialogue Actor component

Post by CHOPJZL »

If instead of converting all Conversants to be a list, but add a "Extra NPCs" list to the conversation, so that Actor and Conversant part will be unchanged. Is this able to maintain support for existing projects?
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: About Dialogue Actor component

Post by Tony Li »

Yes. In fact, you could do it on your own right now. Make a subclass of DialogueSystemTrigger. Add the list. Then override DoConversationAction() to call CharacterInfo.RegisterTransform() with the list items before calling base.OnConversationAction().
CHOPJZL
Posts: 97
Joined: Wed Sep 02, 2020 10:05 pm

Re: About Dialogue Actor component

Post by CHOPJZL »

It's difficult to test, but from my understanding, In this way GetCharacterTransform(id) in ConversationModel will return null, then GetCharacterInfo(int id, Transform character) will return the Info of "Extra NPC", not grumpyMan/grumpyWoman.
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: About Dialogue Actor component

Post by Tony Li »

Hi,

Here is the relevant code in ConversationModel.GetCharacterInfo:

Code: Select all

if (character == null && !string.IsNullOrEmpty(nameInDatabase))
{
    character = CharacterInfo.GetRegisteredActorTransform(nameInDatabase);
}
nameInDatabase will be "Extra NPC".

If you have called CharacterInfo.RegisterActorTransform("Extra NPC", grumpyMan.transform), then the character info will be:L
  • nameInDatabase: "Extra NPC"
  • Name: Grumpy Man
  • Portrait Image: Grumpy Man's image
Will that be useful?
CHOPJZL
Posts: 97
Joined: Wed Sep 02, 2020 10:05 pm

Re: About Dialogue Actor component

Post by CHOPJZL »

Oh, I forgot this part.
This approach seems workable now. Then about UnregisterActorTransform(string actorName, Transform actorTransform). I saw it will do nothing if actorTransform==null. Is it necessary? as it just need actorName to remove. Because it seems difficult to find a good timing to call UnregisterActorTransform, I may call it before StartConversation, too. The actorTransform that is used is not remembered and maybe uncertain.
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: About Dialogue Actor component

Post by Tony Li »

As long as you call CharacterInfo.RegisterActorTransform before starting a conversation, you don't have to unregister it. The most recent RegisterActorTransform will overwrite any previous ones.
CHOPJZL
Posts: 97
Joined: Wed Sep 02, 2020 10:05 pm

Re: About Dialogue Actor component

Post by CHOPJZL »

Sounds good. Then I assume "Extra NPC" should be virtual actor only as placeholder and not has Dialogue Actor component assigned in the scene.
CHOPJZL
Posts: 97
Joined: Wed Sep 02, 2020 10:05 pm

Re: About Dialogue Actor component

Post by CHOPJZL »

But the GetCharacterInfo() is called when "Extra NPC" is the speaker. If there are 2 running conversations(grumpyMan/grumpyWoman) and the first started one's "Extra NPC" speaks later than the beginning of the second conversation, then the "Extra NPC" of the first conversation will become grumpyWoman.
Post Reply