Hello all I have been working with Unity and other game engines/libraries for many years in my spare time. It's been a long twisty road full of joy and pain :D In the last few months or so I have been jumping back in and noticing I really have a good grasp of the basics for almost all aspects of game development (in other words I can happily make little characters move on input in several ways with rigidbody, without rigidbody; Animations I have an ok understanding with; shaders and skyboxes and post processing I kind a barebones knowledge of, etc).

My main issue I always come unstuck with (and end up defeated until I start building a new project which just involves doing the above stuff I listed that I already kinda understand), is managing actual Quests or Special Events throughout the game.

For example, today I'm trying to make a puzzle game (similar to Monkey Island but much much more basic puzzles for now). So you start out in the game stuck inside a room, there are many items in the room , and a door and fireplace. The door is locked. To solve the puzzle you just need to use the Jug of Water on the fire, then you will be able to click the fireplace to climb out of the room.

I've actually made this exact puzzle before and it all worked (I used mainly Strings and had complicated if statements to work out if the player was holding that item). But once I applied this method across a whole game (lets say you keep the empty water jug there and need it in a puzzle way later in game along with some other items etc.) then it gets majorly complicated and seems like not a good way to do it.

I've read lots about text-data types. Apparently its possible to create my own custom commands in text files so that I can annotate the text and use that to trigger methods in my code , but whilst I have read a bit about this on a few forum posts I cannot find much help with coding this (on a very simple beginner level).

I'm hoping I can build a text file that holds items along with dialogue and mission data : Item names; Item description dialogue; Whether they are quest items; Can they be combined (and if so with what and into what);

Ideally, the same system could be used for dialogue (Initial "Hello" with NPC; follow-up conversations; does NPC give quests? if so start one; final (after all quests from this NPC complete) "See ya around!" type dialogue) The text file should be able to help me from what I've read but I dont know how?!?!?

I'm fairly well versed in Polymorphism so like an Item is the parent and then child class might be Food: Item ; Weapon: Item; Tool: Item ,etc. and I also have parsed data from text to make simple pong-breakout style levels (using Json and XML). I feel like that is the way to do it, but Im missing much about adding attributes or custom markup or something like this to my text data.

I know the query here is extremely broad but any broad helpful suggestions of where I can start would be greatly appreciated. Many thanks

  • \$\begingroup\$ There are infinitely many ways to solve this issue. Which one is the best for your particular game is a matter of personal preference. \$\endgroup\$
    – Philipp
    Commented Nov 22, 2018 at 16:09
  • \$\begingroup\$ I'd like to know some options as I have ran out of ideas . My mind is telling me I can create a way of tracking it using XML or Json, but I really cant find a starting point there. And doing it all with strings doesnt seem to work once you get complicated puzzles. I cant think of any other ways to solve the issue yet \$\endgroup\$ Commented Nov 22, 2018 at 16:13
  • \$\begingroup\$ what term might i search on google for this . I struggle to know what to research exactly. Is it "data serialization" ? \$\endgroup\$ Commented Nov 22, 2018 at 16:16

1 Answer 1


Let's build a conceptual framework and then consider the implementation details.

We'll start with our basic building block, the objective. Every objective is either complete or incomplete. Objectives may have additional meta-data attached, e.g. number of items collected and number of items required. Objectives may be composed of other objectives, e.g. objective A requires objective B and objective C.

Let's consider a few examples to flush out the concept a bit. We will use a psuedo json format to represent the data, but remember the implementation does not need to mirror this!

First we want our player to aquire a weapon, we can describe the initial state as follows.

    completed: false,
    requirements: {
        weapon_aquired: false

We want our player to kill 10 boars, but only after they have completed the requisite quest, acquiring a weapon. It could look a bit like this.

    completed: false,
    requirements: {
        kills_left: 10,
        acquire_a_weapon: {
            completed: false

How we implement this can vary widely depending on requirements. Consider an MMORPG where one could expect to maintain the state of a large number of objectives for a large number of players. It might be advantageous to encode quest completion state using a bit field and limit the number of active quests being tracked to reduce meta-data storage requirements (e.g. World of Warcraft only allows 20 active quests per player). Consider a game of rock, paper, scissors where the objective is to win two out of three games. The associated meta-data (number of wins) is relatively small even for a large number of players, encoding the objective as a JSON object can decrease complexity.

Parameters to consider include the amount of data per player you expect to track, the number of players you expect to track simultaneously, and the frequency of reads and writes. These parameters will help you determine how much meta-data to track per player and how to encode it.

  • \$\begingroup\$ Hi thanks very much for this guidance. I'm trying to fully understand it still, but that part about json with the completed: false etc looks exactly what I was thinking of. Also for this particular project there is just one player. But there is a medium amount of items and NPCs to interact with (not like Rock Paper Scis. simplicity but nowhere near WoW -Think more like Monkey Island with say 100 or so objects many of which are useless, and then maybe 20 NPCs that matter that will give you specific items upon completing a quest/riddle of theirs, \$\endgroup\$ Commented Nov 23, 2018 at 0:45
  • \$\begingroup\$ So far I have been working on it whilst waiting for some advice, and I fell back into the trap of it all being String dependent. (I have public fields on the InventoryItem for example, which then I record a List of them to see what is in the inventory. It really makes for a minefield of entering strings into the correct place and making sure I know the string in advance so I can include it in another field inside the object that the item interacts with. The game is super simple and the code is very confusing. I'm sure if I can master the use of Json type data then it will be much cleaner \$\endgroup\$ Commented Nov 23, 2018 at 0:49
  • \$\begingroup\$ The objective system is independent of everything else. Consider a quest which requires a player to have two items, A and B, in their inventory to completed the quest. When the player picks up item a { completed: false, requirements: { has_item_a: true, has_item_b: false, } } When the player drops item a { completed: false, requirements: { has_item_a: false, has_item_b: false, } } \$\endgroup\$ Commented Nov 23, 2018 at 1:00
  • \$\begingroup\$ thanks again, well i think i need to learn how exactly the formatting of the Json works and how exactly to access those bools etc in the Json from within my c# code in Unity. (Sorry for delay I was working away and forgot to look back until now - thanks again for all the help) \$\endgroup\$ Commented Nov 23, 2018 at 3:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .