TopDown Engine Support

This page describes how to set up the Dialogue System with More Mountains' TopDown Engine. (TopDown Engine is required.)

TopDown Engine copyright © More Mountains.

TopDown Engine Support Setup

Import these two packages:

  • Plugins ► Pixel Crushers ► Common ► Third Party Support ► TopDown Engine Support
  • Plugins ► Pixel Crushers ► Dialogue System ► Third Party Support ► TopDown Engine Support

They will unpack files into these folders:

  • Assets ► Pixel Crushers ► Common ► Third Party Support ► TopDown Engine Support
  • Assets ► Pixel Crushers ► Dialogue System ► Third Party Support ► TopDown Engine Support

This integration adds functionality to start conversations within the TopDown Engine framework.

It includes an example scene based on the Koala2D scene. It contains two Dialogue System-enabled NPCs. The ninja in the room directly above the player demonstrates barks. The ninja in the hall (just below this room) demonstrates a conversation.

If the camera doesn't follow the player in this scene or TopDown's original Koala2D scene, make sure the Scripting Define Symbol CINEMACHINE_INSTALLED is set.

If you see a warning about 2D colliders, make sure the Scripting Define Symbol USE_PHYSICS2D is set.

You can set both of these symbols using the Dialogue System's Welcome window (Tools > Pixel Crushers > Dialogue System > Welcome Window).

To play the example scene, you will also need to import the Inventory Engine Support package.

How To Set Up Scenes

Use these steps to set up a TopDown Engine scene for the Dialogue System:

  1. Add a Dialogue Manager (e.g., from Prefabs).
  2. Add a Pause TopDown During Conversations component to the Dialogue Manager or your player prefab(s). If you add it to the Dialogue Manager, it will pause TopDown Engine during all conversations. If you add it to a player prefab, it will only pause during conversations involving that player.
    • Note: You can also add this component to your quest log window. For more info, see Quest Log Window.
  3. If you will allow the player to open the Inventory Engine UI during conversations, add an AllowUINavigationDuringConversations component to the Dialogue Manager.
  4. If the player will be using the gamepad to select response menu buttons, verify that UICamera → EventSystem and Standalone Input Module's inputs are what you want to use. You can usually leave these at the default.
  5. To set up an NPC:
    • Add a trigger collider.
    • Add a Use On Button Activated component.
    • Add a Dialogue System Trigger set to OnUse. Configure it to start a conversation.

If you're using More Mountains' Inventory Engine, see Inventory Engine Support. In particular, please keep in mind that Inventory Engine disables UI navigation while the inventory is closed. If you want to be able to navigate other UIs with a joystick/keyboard such menus, see How To Set Up Scenes.

To perform actions when a character such as an NPC dies or is revived, add an On Death Event component. The example scene uses this component to disable the barking NPC's Bark On Idle component and to deactivate the conversing NPC's Conversation Trigger child GameObject. You can also use it to trigger Dialogue System Triggers for kill quests.

Quest Log Window

To set up a quest log window:

  1. Add an instance to the Dialogue Manager's Canvas (and remove the instance from the Instantiate Prefabs component's list).
  2. You may want to add a Quest Log Window Hotkey. The example scene maps the hotkey 'L' to the quest log window.
  3. Configure the quest log window's OnOpen() event to call PauseTopdownDuringConversations.Pause and OnClose() event to call PauseTopDownDuringConversations.Unpause.
  4. Also untick the quest log window's Pause While Open and Unlock Cursor While Open checkboxes since the PauseTopDownDuringConversations script will take care of it.
  5. If the player can use a mouse, add an MMCursorVisible component to the quest log window's Main Panel child GameObject.

Controlling the Camera

TopDown Engine uses Cinemachine, which keeps a tight grip on camera control. Instead of using Camera() or Zoom2D() commands to control the camera directly, control Cinemachine. First enable Cinemachine support using the Dialogue System's Welcome Window.

Cinemachine uses components called Cinemachine Virtual Cameras (vcams for short) that define how the camera should work (e.g., follow targets, zoom in on a location, etc.). Each vcam has a Priority value. Cinemachine uses the vcam that has the highest Priority. TDE's Koala Dungeon scene has a vcam named "CM vcam1" with a Priority of 10.

You can add another vcam to the scene that focuses on a conversation NPC. Give it a Priority of 0 so Cinemachine doesn't use it during regular play. When the conversation starts, increase its Priority to something higher than 10.

There are two ways you can control a vcam's Priority in a conversation:

  1. Add a Cinemachine Priority On Dialogue Event component to the NPC. Set the dropdown to OnConversation. Assign the vcam.
  2. Or use the CinemachinePriority() sequencer command.

You can use both, too. For example, use Cinemachine Priority On Dialogue Event to prioritize a vcam that focuses on the NPC at the start of the conversation. Say the NPC points to a mysterious object that she wants the player to investigate. Use CinemachinePriority() to prioritize a different vcam that focuses on the mysterious object. Later, use another CinemachinePriority() to drop the priority of the mysterious object vcam. This will cause the NPC's vcam to take effect again.

Saving & Loading

TopDown Engine has a SaveLoadManager. To tie the Dialogue System in, set up the Dialogue System's Save System, add a Dialogue System TopDown Engine Event Listener component to the scene, and tick Handle MM Save Load Events.

Also add this component if you plan to use the Character Persistence component on your player prefab. (Reminder: When using Character Persistence, configure your Corgi Level Manager to instantiate the player from a prefab; don't put the player GameObject directly in the scene at design time.)

If you want to use the Dialogue System's save system as the primary save system, the integration includes a TDECharacterSaver script that you can use as a starting point to save character info. The script saves the character's Health stats.


<< Third Party Integration