[HOWTO] How To: Make Conversation Respond to 3D Object Clicks

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

[HOWTO] How To: Make Conversation Respond to 3D Object Clicks

Post by Tony Li »

This post answers the question:
How would I make a line from a conversation trigger when I click on an object in a 3D game? Basically I want the conversation to go on and to have objects you click on in the world be the way you make decisions for what to say next.
This is an example scene exported from Unity 2020 using the built-in input manager:

DS_ReplyInSceneExample_2022-01-04.unitypackage

The scene has a Cube and a Sphere.

A conversation plays as soon as the scene starts. The first node asks the user to "Click on the sphere." Its Sequence is set to:

Code: Select all

WaitForMessage(ClickedObject)
which will make it wait until it receives the sequencer message "ClickedObject". Sequencer messages are arbitrary strings that you can send from C# or other sequencer commands.

The Sphere has a Dialogue System Trigger that sets a Dialogue System variable named "Object" to the value "Sphere". It also has a small script that, when the object is clicked, invokes the Dialogue System Trigger and then sends the sequencer message "Clicked Object".

The Cube is set up similarly except it sets the "Object" variable to "Cube".

The conversation then checks whether the "Object" variable is set to "Sphere" or not. Note that Conversations Evaluate Conditions One Extra Level Ahead so there's an intermediate node between the first node and the nodes that check the "Object" variable. [Note: The intermediate node isn't necessary if you've ticked the Dialogue Manager's Other Settings > Reevaluate Links After Subtitle checkbox.]

You can use this same idea for tutorial conversations. Use the WaitForMessage() sequencer command to make the conversation wait for the player to complete a task in the tutorial.
Post Reply