Forums › 💬 NodeCanvas › ⚙️ Support › [DialogTree] Accessing actors on Multiple Choice Node
Hi,
I’m making the UI for the dialogues on my game, and I have a problem with the Multiple Choice Node. My characters “says” every choice (you navigate trhought them using the text bubbles) but I have no access to the actor of this Node, so, I can’t know who must say it.
The “say choice” doesn’t help, because this only works with the selected choice.
Any way I can access the “finalActor” on the Multiple Choice Node?
Thanks for your help!
Cheers.
Hello,
Sorry, but I’m afraid I did not understand the problem 🙂
If you are making a custom UI, then you can know which actor is to say the statement from the SubtitlesRequestInfo that is the parameter of the OnSubtitlesRequest event.
|
1 2 3 4 5 6 7 |
void OnSubtitlesRequest(SubtitlesRequestInfo info){ var text = info.statement.text; var audio = info.statement.audio; var actor = info.actor; } |
So, you dont have to dig into the dialogue tree or the nodes since all information needed is passed within the events raised.
Let me know if that helpds.
Thanks.
Hi, sorry for not answering earlier, I didn’t get a notification.
I did that for single request nodes, my problem is that “MultipleChoiceRequestInfo” doesn’t include the Actor of the “Question” itself. I need the actor because in my game the character says every option of the MultipleChoice nodes with a portrait, and that info is in the actor.
For example, in the screenshot attached, the character will say “0”, then you can navigate trought “Choice 1” and “Choice 2” with the same UI. Once selected, It will say the next option. I need the actor for the navigation part trought the options.
Thanks a lot!
Cheers.
Hey,
Indeed the MultipleChoiceRequestInfo does not contain the IDialogueActor that is selected in the node. I just added this now.
If you want to add it as well, please make the following changes:
1) In MultipleChoiceNode.cs, change line #70 to the following:
|
1 2 3 |
var optionsInfo = new MultipleChoiceRequestInfo(finalActor, finalOptions, availableTime, OnOptionSelected); |
2) In DialogueEventArguments.cs, change class MultipleChoiceRequestInfo to the following:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
///Send along with a OnMultipleChoiceRequest event. Holds information of the options, time available as well as a callback to be called providing the selected option public class MultipleChoiceRequestInfo{ ///The actor related. This is usually the actor that will also say the options public IDialogueActor actor; ///The available choice option. Key: The statement, Value: the child index of the option public Dictionary<IStatement, int> options; ///The available time for a choice public float availableTime; ///Should the previous statement be shown along the options? public bool showLastStatement; ///Call this with to select the option to continue with in the DialogueTree public Action<int> SelectOption; public MultipleChoiceRequestInfo(IDialogueActor actor, Dictionary<IStatement, int> options, float availableTime, bool showLastStatement, Action<int> callback){ this.actor = actor; this.options = options; this.availableTime = availableTime; this.showLastStatement = showLastStatement; this.SelectOption = callback; } public MultipleChoiceRequestInfo(IDialogueActor actor, Dictionary<IStatement, int> options, float availableTime, Action<int> callback){ this.actor = actor; this.options = options; this.availableTime = availableTime; this.SelectOption = callback; } } |
Let me know if that works for you.
Thanks!
Hi!
That worked perfect, thank you very much!
Cheers!
Great!
Thanks for letting me know, and glad I could be of help!
I will of course keep this change in there for the next version as well 🙂
Cheers!
