ORK Framework Logo - RPG Editor for Unity
  • ORK 4 BETA
  • Features
  • Guide
    • Documentation
    • Tutorials
    • API
  • ORK 2
    • Tutorials
    • Plugins
    • API
  • Support
  • Forum
  • Get ORK

ORK 4 Documentation

  • Getting Started
    • Welcome
    • First Steps (Unity)
  • Features
    • The Status System
    • Schematics
    • Schematic Nodes
    • Dialogue Importer
    • Variables
    • Selected Data
  • Components
    • Battle Components
    • Combatant Components
    • Control Components
    • Cursor Prefab Components
    • Game Starters
    • Interactable Components
    • Move AI Components
    • Scene Setup Components
  • Editor
    • The ORK 4 Editor
    • Sections & Sub-Sections
    • Node Editor
    • Schematic Editor
    • Asset Sources
    • Unity Overlay Toolbar
  • Section: System
    • System Settings
    • Languages
    • Organizer Types
    • Game States & Conditions
    • General Condition Templates
    • Object Pools
    • Prefab Savers
    • Scene Connections
  • Section: Controls
    • Game Controls
    • Interaction Settings
    • Player Controls
    • Camera Controls
    • Input Keys
    • Control Maps
    • Camera Positions
    • Battle Camera
  • Section: Gameplay
    • Game Settings
    • Formulas
    • Difficulties
    • Shortcut Slots & Settings
    • Custom Settings & Global Custom Settings
    • Global Machines
    • Machine Templates
  • Section: Status
    • Status Values
    • Status Effects
    • Attack Modifiers
    • Defence Modifiers
    • Abilities & Ability Developments
    • Status Developments
    • Research Trees
    • Damage Types
    • Status Bonuses & Templates
    • Status Condition Templates
  • Section: Inventory
    • Inventory Settings
    • Inventory Containers
    • Currencies
    • Items
    • AI Rulesets
    • Crafting Recipes
    • Equipment Slots & Slot Set Templates
    • Equipment & Available Equipment Templates
    • Shops
    • Loot
  • Section: Combatants
    • Combatants
    • Combatant Groups
    • Class Slots
    • Classes
    • Factions & Faction Benefits
    • Animations
    • Move AIs
    • Formations
    • Action Combos
  • Section: Battles
    • Battle Systems
    • Turn Based Battles
    • Active Time Battles
    • Real Time Battles
    • Phase Battles
    • Battle Spots
    • Battle AIs
    • Battle Actions Settings
    • Special Commands Settings
    • Target Settings
    • Target Selection Templates
    • Battle Range Templates
    • Battle Grid Settings
    • Battle Grid Highlights
    • Battle Grid Cell Types
    • Battle Grid Formations
  • Section: Content
    • Content Types
    • Music
    • Sound Templates
    • Areas
    • Teleports
    • Quests & Quest Tasks
    • Logs & Log Texts
    • Object Contents
  • Section: UI
    • UI Settings
    • UI Layers
    • UI Layouts
    • UI Boxes
    • HUDs
    • Notifications
    • Cursor Settings
  • Section: Menus
    • Start Menu
    • Save Game Settings
    • Option Categories
    • Menu Screens
    • Menu Requirements
    • Battle Menus
    • Loot Dialogues
    • Item Collection
    • Combatant Selections
    • Quantity Selections
    • Shop Layouts
  • Section: Texts
    • Text Settings
    • Formatting Settings
    • Flying Texts
    • Use Cost Display
    • Status Preview Display
    • Bonus Display
    • Status Change Display
    • Console Settings & Console Types
    • Text Codes
  • Sections: Editor
    • Editor Settings
    • Backups
    • Variables
    • Plugins
  • Scripting
    • Access Handler
    • Custom Nodes
    • Custom Save Data
    • Custom Component Save Data

ORK 4 Tutorials

  • ORK 4 Unity Quickstart Tutorials (3D)
    • ORK 4 Unity Quickstart 3D
    • 01 Initial ORK Setup
    • 02 Player Setup
    • 03 Music & Scenes
    • 04 UI System Setup
    • 05 UI Boxes
    • 06 Flying Texts
    • 07 Status Values
    • 08 Status Effects
    • 09 First Abilities
    • 10 Fighter Setup
    • 11 First Enemies & Battle AI
    • 12 Battle System Setup
    • 13 Animating Battle Start and End
    • 14 Random Battles
    • 15 Animating Actions
    • 16 Player Battle HUD
    • 17 Elemental Attacks
    • 18 Animating More Actions
    • 19 Inventory & Loot
    • 20 Equipment
    • 21 Loot, Start Equipment & Viewers
    • 22 Magic Abilities
    • 23 Caster Setup
    • 24 More Enemies
    • 25 Start Menu & Save Games
    • 26 Menu Screens
    • 27 Interactions
    • 28 Item Collectors
    • Quickstart Extended
  • Battle Tutorials
    • Adding Active Time Battles
    • Adding Phase Battles
    • Hit & Miss
    • Critical Hits
    • Cast Time
    • Grid 01: Battle Grid Setup
    • Grid 02: Highlights
    • Grid 03: Cell Types
    • Grid 04: Move Command
    • Grid 05: Scene Grid Setup
    • Grid 06: Battle Ready
    • Grid 07 Use & Affect Ranges
    • Grid 08: Better Camera Control
  • Gameplay Tutorials
    • Multiple Interaction Controllers
    • Player Group Spawn & Follow
    • Spawn Hunting Enemies
    • Gamepad Controls (Unity Input System)
    • Combined Inputs
    • Quests 01: Menu Screen
    • Quests 02: Hunting
    • Quests 03: Collect Potion Materials
    • Quests 04: Collect Equipment Materials
    • Quests 05: Quest Mark HUDs
    • Crafting 01: Menu Screen
    • Crafting 02: Materials & Recipes
    • Crafting 03: Getting Materials
    • Crafting 04: Proficiency & Critical Outcome
    • Shop
    • Inventory Containers
  • Schematics Tutorials
    • UI Animation Schematics
    • Flying Text Animation Schematics
    • HUD Conditional Schematics
  • UI Tutorials
    • Unity UI: Initial Setup
    • Unity UI: Status Value UI Setup
    • Unity UI: Status Effect UI Setup
    • Unity UI: Shortcut UI Setup
    • Unity UI: Dragging Notification
    • Unity UI: Interaction HUD
    • Unity UI: Shortcut HUD
    • Unity UI: Turn Order HUD
    • Unity UI: Cast Time HUD
    • Unity UI: Quest HUD
    • Unity UI: Tooltip HUD
    • Unity UI: Move Range HUD

ORK 4 Extensions

  • Plugins
    • Save Game Compression Plugin
  • Schematic Nodes
    • Footstepper Nodes (Unity)
  • Scripts
    • A* Pathfinding Movement Component (Unity)
    • PolyNav 2D Movement Component (Unity)
    • Cinemachine Camera Control Type (Unity)
    • Rewired Input Key (Unity)
    • Unity Legacy Input Key (Unity)
    • Core GameKit Wrapper (Unity)
    • Pool Boss Wrapper (Unity)
View Categories
  • Guide
  • ORK 4
  • ORK 4 Tutorials
  • ORK 4 Unity Quickstart Tutorials (3D)

27 Interactions

In this tutorial we’ll add an NPC to speak to.

Speaking to an NPC, collecting an item … these are interactions with the game world.

For the player to be able to interact with something, we need an Interaction Controller.

We’ll set up

  • interaction controller (prefab + setup)
  • a dialogue schematic
  • NPC in town

Let’s get to it!

Interaction Controller #

The Interaction Controller is used to interact with any interaction within it’s trigger when the player uses the Interact key.

You can even use multiple interaction controllers on the combatant to interact with different things at different distances, e.g. speaking to an NPC when standing before it but collecting items all around.

We’ll create a prefab that’s automatically added to the player.

Prefab Setup #

We start with setting up the prefab – you can do this in any of the scenes.

As usual this is pretty easy using the scene hierarchy’s context menu (ORK Framework > Interaction Controller (3D)) or the ORK toolbar (search for: Interaction Controller 3D).

Change the following settings in the inspector.

Interaction Controller Component #

  • Interact With Nearest
    Enable
    This’ll interact with the interaction that’s closest to the interaction controller.
    Depending on your game’s setup, there might be multiple interactions available at the same time.

Box Collider Component #

  • Size
    Set to: X=1.5, Y=3, Z=1

The finished interaction controller should look like this.

Create Prefab #

Create a prefab out of the Interaction Controller (3D) object.

Remove the object from the scene.

Interaction Settings #

Open the ORK editor and navigate to Controls > Interaction Settings.

We’ll now set up to automatically add the interaction controller to our player.

Base Settings #

The default setup should already use an interaction controller and the Accept input key.

  • Interaction Control
    Select: Interaction Controller
  • Interact Key
    Select: Accept

Interaction Controller Settings #

These settings handle adding our prefab to the player.

  • Add Automatically
    Enable
  • IC Prefab
    Select: Interaction Controller
  • Local Space
    Enable
  • Offset
    Set to: X=0, Y=1.5, Z=1
    This’ll place the interaction controller at a position matching our player combatant prefabs.

Save Changes #

Save the changes before we set up the dialogue schematic.

Don’t forget to save your changes by clicking on Save Settings at the bottom of the editor.

Dialogue Schematic #

We’ll set up a dialogue that has changing messages each time we talk to the NPC.

This is done by using object variables on our NPC’s object. We’ll use a long variable with the variable key counter to count the dialogues.

Open the schematic editor.

Settings #

  • Block Player Control
    Enable
    We don’t want our player to run around while talking to the NPC.

Speakers #

We’ll set up a speaker for our dialogues.

Click on Add Speaker.

  • Object (Speaker Object)
    Select: Machine Object
    The Machine component we’ll use to start the dialogue will be placed on the NPC, so the machine object will be the NPC’s object.
  • Custom Object Content
    Enable
    We’ll define a custom content here.
    Otherwise, you can set up object content and add it to the NPC’s object.
  • Name
    Set to: Random Citizen

Variable Fork #

Add Node > Value > Variable > Variable Fork

This node is used to check a single variable for multiple values – each value check has it’s own next slot to continue from.

We’ll cycle through 3 different dialogues, so we’ll need 3 conditions.

  • Variable Key
    Set to: counter
  • Variable Origin
    Select: Object
    This’ll use object variables attached to an object (via an Object Variables component).
  • Object
    Select: Machine Object

There’s already a variable condition added for us, so let’s change Variable Condition 0 to our needs.

  • Type
    Select: Long
  • Check Type
    Select: Is Equal
  • Check Value
    Select: Value > Value
    Set the value to: 0
    0 is also the default value for any not yet set int variable (for bool variables it’d be false, for string an empty text, etc.).

Copy Variable Condition 0.

  • Check Value
    Set the value to: 1

Copy Variable Condition 1.

  • Check Value
    Set the value to: 2

Show Dialogue #

Add Node > UI > Dialogue > Show Dialogue

We’ll show the first dialogue.

This node is connected to the is Equal 0 slot of the Variable Fork node.

  • Dialogue Type
    Select: Message
    We simply display a message text.
  • UI Box
    Select: Dialogue

The Speaker Settings handle if a speaker is used, e.g. to display a name in the UI box’s title content.

  • Use Speaker
    Enable
  • Actor
    Select: Speaker 0: Random Citizen
  • Show Name
    Enable
  • Text (Message Content)
    Set to: Hello there!

Show Dialogue #

Copy the previous Show Dialogue node.

This node is connected to the is Equal 1 slot of the Variable Fork node.

We’ll just change the message.

  • Text (Message Content)
    Set to: Can I help you?

Show Dialogue #

Copy the previous Show Dialogue node.

This node is connected to the is Equal 2 slot of the Variable Fork node.

We’ll change the message again.

  • Text (Message Content)
    Set to: Please go away …

Change Variables #

Add Node > Value > Variable > Change Variables

We’ll now increase the counter variable by 1.

This node is connected the Next slots of all Show Dialogue nodes.

Click on Add Variable.

  • Change Type
    Select: Variable
  • Variable Key
    Set to: counter
  • Variable Origin
    Select: Object
  • Object
    Select: Machine Object
  • Type
    Select: Long
  • Operator
    Select: Add
  • Float Value
    Select: Value > Value
    Set the value to: 1

Change Variables #

Copy the previous Change Variables node.

We’ll now set the counter variable to 0 in case the initial Variable Fork check failed.

This node is connected the Failed slot of the Variable Fork node.

Connect the node’s Next slot back to the Variable Fork node – i.e. if the fork failed, it resets the variable and checks again, restarting the dialogue.

  • Operator
    Select: Set
  • Float Value
    Set the value to: 0

And that’s it for the schematic – save it, e.g. as ChangingDialogue.

Adding the NPC #

Open the World scene – we’ll now add the NPC to talk to.

Add one of the NPC prefabs to the town, you can find the NPC prefabs in Assets/Tutorial Assets/Prefabs/NPCs/ – I’m using the Casual_Bald prefab and place it somewhere in the center of the town.

Object Variables Component #

Add an Object Variables component to the NPC’s object using the component menu.

This component is used to bind object variables to an object and allows the Object variable origin to find variables on an object.

Object variables can either persist and be shared between multiple objects by using the same Object ID to identiy them, or be used as local variables. We’ll use them as local variables, i.e. they’re only accessible for this object, not shared and not saved with save games. Once the object is destroyed (e.g. when we change scenes), they’ll be gone. That’s all we need for our changing dialogue.

  • Local Variables
    Enable

Machine Component #

Add a Machine (Schematic) component to the NPC’s object using the component menu.

Start Settings #

Click on Interact, this will add the Interact start type.

If you want, you can also add mouse interaction, click on Add Start Type.

  • Start Type
    Select: Interaction > Mouse Up As Button

Expand the Object Turn Settings, we’ll let the player and NPC face each other.

  • Turn Starting Object
    Enable
  • Turn Component Object
    Enable

Asset Settings #

  • Schematic Asset
    Select: ChangingDialogue

And that’s it – save the scene.

Testing #

Hit play and walk up to the NPC.

Using the accept input key (Space) lets us speak with the NPC and cycle through the dialogue.

 

Next, we’ll add items to collect.

Table of Contents
  • Interaction Controller
    • Prefab Setup
      • Interaction Controller Component
      • Box Collider Component
      • Create Prefab
    • Interaction Settings
      • Base Settings
      • Interaction Controller Settings
  • Save Changes
  • Dialogue Schematic
    • Settings
      • Speakers
    • Variable Fork
    • Show Dialogue
    • Show Dialogue
    • Show Dialogue
    • Change Variables
    • Change Variables
  • Adding the NPC
    • Object Variables Component
    • Machine Component
      • Start Settings
      • Asset Settings
  • Testing
Sitemap
  • ORK 4 BETA
  • Features
  • Showcase
  • Guide
    • Documentation
    • Tutorials
    • API
  • ORK 2 Hub
    • Tutorials
    • Plugins
    • API
  • Support
  • Forum
  • Get ORK
  • Contact
  • Blog
  • Makinom
  • gamingislove.com
Categories
  • News (73)
  • ORK 2 (137)
    • Tutorial (137)
      • Game tutorial (50)
      • Gameplay (32)
      • How-to (55)
  • Release (156)
Search

© 2015 Gaming is Love e.U.

Disclosure: This site may contain affiliate links, which means I may receive a commission if you click a link and purchase something that I have recommended. While clicking these links won’t cost you any money, they will help me fund my development projects while recommending great assets!