I am busy learning how to use the Dialogue system, so I’ve set up a basic dialogue tree for generic interactions between the player and NPCs. Depending on the option the player chooses, the player might initiate trading or have the NPC follow them. At the end of each multi-choice option I just call a method in my code base, but the problem is I don’t know which NPC the dialogue was engaged with.
Of course when I kicked off the dialogue, I replaced the placeholder NPC in my tree with the actual actor (since there can be many NPCs with the same sort of interaction). So when I kick off the interaction I simply look-up the actor by placeholder name. However, I feel like there should be a better approach. Is there a way I can pass in a reference to the function of the relevant actor being talked to? I could just add a string parameter to the function with the actor’s name to do a look-up on, but I’d perhaps like to have a dropdown list here of all actors so I don’t have to manually type the name, kind of like the DialogueActor list you get on every Dialogue node by default (but instead have it here as a function parameter).
Hmm… Right now this is not possible since Dialogue Actor parameters are not treated the same way as variables do (which can be passed as a reference to a function parameter called with the Execute Function action).
Being possible to do this, I can see being useful and thus I will take a look at this possibility. Thinking about this, I could add a “special” variable in the dropdown called “Self”, which will always reference the “agent” of the node (thus the actor selected) and would work similar to how “Self” works when selecting the target agent for a task.
Well, there’s already “Self” on the execute function task which I can use to access the owner of the node (which corresponds to the dialogue actor associated with the node if I understand correctly). Well that’s exactly what you said in your last sentence, but how will this allow me to reference other actors involved in the dialogue? I’m new to all of this. Also not sure which dropdown list you are referring to. Whatever you think is best 🙂
I think a decent solution for me would be to set the agent my player is interacting with on the dialogue tree’s blackboard from code at the same point I am replacing the placeholder agent. Then I can just access that agent via the blackboard.
Indeed, one solution for you would be exactly what you suggest; to set and use a blackboard variable for the actor.
You are also probably right about “self”. A better implementation, would be to be possible for the actors to show and be selected like variables do in the variable selection dropdown.
Unfortunately though, actor parameters are not treated the same way and are not blackboard variables per-se (code architecture wise), since actor parameters are specific to Dialogue Trees, while Blackboard Variables are common in all graph systems.
I would have to think of something else, but once again, your suggested solution is probably better until then 🙂