QUEST 05 Quest Mark HUDs

In this tutorial we’ll set up our quest objects in the scene.

This tutorial continues the sub-series for setting up quests.

We’ll set up 2 HUDs, one for marking game objects that start new quests and one for marking game objects that are part of active quest.

HUD Prefabs #

First, we’ll set up 2 HUD prefabs – we’ll keep it simple and just display an icon (sprite).

New Quest HUD #

We use the scene hierarchy’s context menu to create an empty HUD without any layout: Makinom > HUD > HUD

Rect Transform #

The HUD will be placed at the position of a game object in the scene, so we only adjust the width and height.

  • Width
    Set to 50.
  • Height
    Set to 50.

Image #

Add an Image component to the HUD game object using the component menu.

  • Source Image
    Select icons_14.

Create Prefab #

That’s already all we need to do.

Create a prefab out of the HUD game object (without the canvas), e.g. name it Quest New HUD.

Progress Quest HUD #

We’ll adjust the still added HUD game object for our 2nd HUD.

Image #

We simply use a different icon.

  • Source Image
    Select icons_15.

Create Prefab #

That’s already all we need to do.

Create a new prefab out of the HUD game object (without the canvas), e.g. name it Quest Progress HUD.

HUD Setup #

Open the editor and navigate to UI > HUDs, we’ll add 2 new HUDs.

Quest New #

We’ll use Object HUDs, they are displayed at game objects and also have to be added to them using an Object HUD component.

HUD Settings #

  • Name
    Set to Quest New.
  • HUD Type
    Select Object.
  • Auto Display
    Enable this setting.

Object Settings #

  • Path to Child
    Set to HUD.
    We’ll also need to add this child object for placing the HUD to our game objects (we’ll add it to the NPC prefabs).
  • Use Range Limit
    Enable this setting.
    We’ll only show the HUD if the player is within a defined range of the game object.
  • Range
    Select Value > Value.
    Set the value to 40.
  • Threshold
    Select Value > Value.
    Set the value to 1.

Display Conditions > Game State Condition #

We’ll check fo our game state managing battle HUDs.

Click on Add Game State.

  • Condition Type
    Select Game State.
  • Game State
    Select In Control.
  • Check State
    Select Active.

Unity UI #

  • UI Layout
    Select HUDs.
  • HUD Prefab
    Select the Quest New HUD prefab.

Quest Progress #

Copy the Quest New HUD.

HUD Settings #

  • Name
    Set to Quest Progress.

Unity UI #

  • HUD Prefab
    Select the Quest Progress HUD prefab.

Save Settings #

That’s it for the HUD setup – we’ll now add the HUD to game objects in the scene.

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

Updating NPC Prefabs #

Before adding the HUD, we’ll add the HUD child object for placing the HUD to our quest-related NPC prefabs.

You can find the NPC prefabs in Assets/Tutorial Assets/Prefabs/NPCs/. I’m updating the Witch and Knight_Male prefabs, but feel free to add it to all NPCs.

Open the prefab for editing.

Add a new empty game object to the Witch root game object and name it HUD.

Transform #

Change the position of the added HUD game object.

  • Position
    Set to X=0, Y=4, Z=0.

Witch NPCs #

Now, we’ll add the quest mark HUDs to the 3 witch NPCs.

Town Witch #

Add an Object HUD component to the WitchTown game object using the component menu.

We don’t need to add a condition to display this HUD, because the game object is only here when the quest is available.

  • Object HUD
    Select Quest New.

Forest Witch #

Add an Object HUD component to the WitchForestRuins game object using the component menu.

The HUD should display when either the Meet at the ruins task or the Bring items to the witch task is active.

  • Object HUD
    Select Quest Progress.

Click on Add Condition.

  • Condition Type
    Select Quest Task.
  • Needed
    Select One.

Click on Add Task Condition.

  • Quest Task
    Select Meet at the ruins.
  • Check Status
    Select Active.

Copy Task Condition 0.

  • Quest Task
    Select Bring items to the witch.

Outpost Witch #

Add an Object HUD component to the WitchOutpost game object using the component menu.

The HUD should display when either the Meet the witch in the outpost task is active.

  • Object HUD
    Select Quest Progress.

Click on Add Condition.

  • Condition Type
    Select Quest Task.

Click on Add Task Condition.

  • Quest Task
    Select Meet the witch in the outpost.
  • Check Status
    Select Active.

Guard NPC #

The town’s guard also gives us quests, so we’ll add HUDs to him as well.

We’ll display both quest mark HUDs, depending on the state of the quests/HUDs. If the Report to the guard task is active (from Hunt Dragon quest), we’ll display the Quest Progress HUD, if either of the hunting quests is not added or finished and the Report to the guard task is not active, we’ll display the Quest New HUD.

Add an Object HUD component to the Knight_Male game object (in the town) using the component menu. The component can manage multiple HUDs, so we only need that one component.

Object HUD 0 #

First, we’ll set up the quest progress HUD.

  • Object HUD
    Select Quest Progress.

Click on Add Condition.

  • Condition Type
    Select Quest Task.

Click on Add Task Condition.

  • Quest Task
    Select Report to the guard.
  • Check Status
    Select Active.

Object HUD 1 #

We basically need to negate the other HUD’s check and an add additional condition checking for other quest states.

Copy Object HUD 0.

  • Object HUD
    Select Quest New.

Condition 0 > Task Status Condition 0 #

  • Is Valid
    Disable this setting.

Condition 1 #

Click on Add Condition.

  • Condition Type
    Select Quest.
  • Needed
    Select One.

Click on Add Quest Condition.

  • Quest
    Select Hunt Wasps.
  • Check Status
    Select Not Added.

Copy Quest Status Condition 0.

  • Quest
    Select Hunt Skeletons.

Copy Quest Status Condition 1.

  • Quest
    Select Hunt Supporters.

Copy Quest Status Condition 2.

  • Quest
    Select Hunt Dragon.

Copy Quest Status Condition 3.

  • Check Status
    Select Finished.

Copy Quest Status Condition 4.

  • Quest
    Select Hunt Supporters.

Copy Quest Status Condition 5.

  • Quest
    Select Hunt Skeletons.

Copy Quest Status Condition 6.

  • Quest
    Select Hunt Wasps.

And that’s it for our setup – don’t forget to save your scene.

Testing #

Hit play and run to one of the quest NPCs.

Seems like there’s a new quest available.

And our quest progress NPC is also marked – great!

Next, we’ll look into research trees to upgrade abilities with our magic crystals.