20 Mins
You have completed 0% of this Tutorial.
InfoZone Prefab
To finish off the gameplay elements of each Switch, you need to find a way to tell the user what the Switch does, and why it’s important.
Recommended Unity Versions
InfoZone Prefab
A common way to do this is via dialogue from the protagonist to the player. The 3D GameKit Lite achieves this with an InfoZone Prefab.
  • In the Project view, go to 3DGamekitLite > Prefabs > Interactables and select the InfoZone Prefab.
Drag InfoZone into the Hierarchy window under the ---- UI ---- section header. Remember to add it below the section header, and not as a child GameObject of it.
  • The InfoZone GameObject has a Sphere Collider component, which appears in the Scene as a large green sphere. Move this over the Switches, and resize it to include all three. This defines the area in which Ellen needs to stand to trigger the dialog, so don’t make it too big.
  • In the Inspector window, set Layer to Environment if Unity has not set it automatically.
  • On the Sphere Collider, enable Is Trigger.
Now we need to link the InfoZone to the DialogueCanvas Prefab, which uses Game Commands to give the player information about the Switches when they enter the trigger zone.
  • Go to 3DGamekitLite > Prefabs > UIPrefabs and find the DialogueCanvas Prefab.
  • Drag a DialogueCanvas into the Hierarchy window and place it under the ---- UI ---- section header.
  • Deactivate it by unticking the checkbox at the top of the inspector next to the name.
  • Later, we’ll set this up so that it only activates when Ellen enters the trigger zone of the InfoZone.
Select the InfoZone in your Scene and find the Interact On Trigger component in the Inspector window.
  • Set Layers to Player if Unity has not set it automatically.
  • Set On Enter () and On Exit () to the Dialogue Canvas Controller script. To do this, drag the script into the empty slot for each one.
Under On Enter (), select the drop-down that reads No Function and change it to DialogueCanvasController.ActivateCanvasWithText.
Update the text field to provide some useful text to the player. This example uses the following: “If I switch all of these on maybe the door will open.”
  • Under On Exit (), select the drop-down that reads No Function and change it to DialogueCanvasController.DeactivateCanvasWithDelay, then set the value field beneath it to 1.
To test that your set-up works, press Play and walk towards the Switches. The dialog box with the text should appear when you get close to them.
Now that this is all set up, you can move the Switches and Crystals to other areas, or hide them from the player to make it more challenging. The Game Command links remain attached when you move things around, so you can use the GameObjects more dynamically in your level. You can also add the DialogueCanvas to any areas where you require the player to be notified of key gameplay mechanics in your Project.