Page 12 of 14
Re: About Dialogue Actor component
Posted: Wed Apr 14, 2021 10:41 am
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.
Re: About Dialogue Actor component
Posted: Wed Apr 14, 2021 11:14 am
by CHOPJZL
Is it workable when "Extra NPC" exists in multiple running conversations?
Re: About Dialogue Actor component
Posted: Wed Apr 14, 2021 11:42 am
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?
Re: About Dialogue Actor component
Posted: Wed Apr 14, 2021 1:12 pm
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().
Re: About Dialogue Actor component
Posted: Wed Apr 14, 2021 8:47 pm
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.
Re: About Dialogue Actor component
Posted: Wed Apr 14, 2021 9:06 pm
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?
Re: About Dialogue Actor component
Posted: Wed Apr 14, 2021 9:37 pm
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.
Re: About Dialogue Actor component
Posted: Wed Apr 14, 2021 9:40 pm
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.
Re: About Dialogue Actor component
Posted: Wed Apr 14, 2021 9:57 pm
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.
Re: About Dialogue Actor component
Posted: Thu Apr 15, 2021 8:28 am
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.