Trigger a function within a conversation that knows what the interacting gameobjects are

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
niskander
Posts: 9
Joined: Thu Jan 07, 2021 2:58 pm

Trigger a function within a conversation that knows what the interacting gameobjects are

Post by niskander »

Hi all, I just started using this system and I need to do something pretty basic but I can't find any examples for it. Please let me know if I'm missing anything. Here's what I want to do:

When a player selects a certain node in the conversation, I want to trigger a function that knows what the interacting game objects are (actor and conversant).
I've seen how to trigger a C# function from conversation nodes, but I don't see a way of passing the interacting game objects to that function.
I guess I could pass unique IDs and try to get the objects that way, but that seems inefficient and unnecessary since the conversation already knows who the conversant and actor are.

For context: I'm trying to make a simple interaction where a player can interact with an item and choose whether to inspect, take, or leave. (Players and items are spawned dynamically).
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Trigger a function within a conversation that knows what the interacting gameobjects are

Post by Tony Li »

Hi,

Your C# method can check DialogueManager.currentActor and currentConversant. Those will correspond to the conversation actor and conversant. Example:

Code: Select all

public void TakeCurrentConversant()
{
    YourInventorySystem.PickUpItem(DialogueManager.currentConversant);
}
You can also check the current dialogue entry's speaker and listener using DialogueManager.currentConversationState.subtitle.speakerInfo and listenerInfo.
niskander
Posts: 9
Joined: Thu Jan 07, 2021 2:58 pm

Re: Trigger a function within a conversation that knows what the interacting gameobjects are

Post by niskander »

Thanks a lot for the response, that will do!
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Trigger a function within a conversation that knows what the interacting gameobjects are

Post by Tony Li »

Happy to help!
Post Reply