Search Unity

Creating and maintaining game text - best practices

Discussion in 'Game Design' started by taivasltd, Mar 27, 2019.

  1. taivasltd

    taivasltd

    Joined:
    Mar 27, 2019
    Posts:
    20
    Hi all,

    I have done some search around and found information here and there but not exactly what I have in mind:

    I am building a game with a lot of dialogue and text stuff (E.g. text when picking/observing/using an object, when navigating in a room, when chatting with a character etc etc). I am thinking that it makes sense that the game is separated in Rooms (i.e. a scriptable object that will have a series of common properties)

    Now all the text will be precreated obviously and the relevant text should be loaded when player enters a room.

    So if we take an example:

    -Player enters Main Hall

    -Main Hall has text related to:

    ---->What exits there are
    ---->Characters you can chat with (with dialogue containing choices some times)
    ---->Items you can pick/observe/use

    Let's assume Main Hall has
    --->Exit to the north
    --->A character you can talk to
    --->A flashlight you can pick
    --->A key you can use

    I am thinking that this is about building a database. So when user enters main hall with e.g. room_id = "mainHall", then we load all that information (so that we don't need to query all the time the room_id with every new action the user takes)

    What is the best way to have all that text info stored within the game and load the relevant Room info when player enters? Is it to have a big json (or for example a json per room) and load it?

    I hope the question makes sense, pls ask for specifications as it's not easy to write everything that goes on in my head :D

    Thank you
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Putting that text into separate documents of some sort is a great idea. And I would indeed recommend some text-based serialization format (I prefer GRFON, but JSON would work in a pinch), so that it will play nicely with version control systems, easy diff/patch, online multi-user text editors, etc.

    Whether you use one giant file, or a smaller file per room, is up to you. Probably the more granular (per-room) file structure is better, just because it will make it even easier to collaborate with others, roll back one part of the world but not another, etc.
     
    angrypenguin likes this.
  3. taivasltd

    taivasltd

    Joined:
    Mar 27, 2019
    Posts:
    20
    thanks JoeStrout great advice :) I think I will start like this then; in my head having a "library" of folders and rooms/files sounds like a clean way to maintain and extend things. let's see :D
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Databases don't play nice with version control. I'd agree with @JoeStrout that a text file in some form would be a better choice.
     
    angrypenguin likes this.
  5. taivasltd

    taivasltd

    Joined:
    Mar 27, 2019
    Posts:
    20
    thanks Joe! :)
     
  6. Volcanicus

    Volcanicus

    Joined:
    Jan 6, 2018
    Posts:
    169
    I am actually working on a game with 100 NPCs that have a variant dialogue based around each 15 mins for 7 days. So that's 4x24x7x100 = 67200 base texts in addition to choices. And after discussing it with folks with more experience than me, turns out a database isn't necessary for this. In fact a simple CSV file is enough. So i will make the same recommendation.
     
  7. taivasltd

    taivasltd

    Joined:
    Mar 27, 2019
    Posts:
    20
    thanks Volcanicus! seems this is the path to go then! and I like the idea of a neat library of static but also easily extensible resources! good luck with your game ;)
     
  8. DungeonBrickStudios

    DungeonBrickStudios

    Joined:
    Jun 9, 2015
    Posts:
    69
    The separate file approach also works great when it comes to localization. You just give the translator the file containing the key/string pairs, and they translate just the strings. So in your game, all the text would automatically be translated when you tell it to load the, for example, Russian dictionary of keys/strings.
     
    angrypenguin likes this.
  9. taivasltd

    taivasltd

    Joined:
    Mar 27, 2019
    Posts:
    20
    Thanks!

    So I have an additional question: I am structuring this "library" of json files, using a single structure to keep it concise i.e. each room has exits[], dialogues[], a description, a room_id etc etc.

    So my lib looks like
    StreamingAssets --->DataLib-----> Room1--->data.json (and similar path for the other rooms)

    Now, although I like the idea giving players freedom to build whatever they want, from a quick search I read that StreamingAssets stuff are exposed to the user; so if tomorrow let's say I launch the game for PC, they can go and find those json files and change them (or see for example data that would come much later in the game etc).

    1. Is my assumption about StreamingAssets correct? If so, sounds like it's the wrong place to put these
    2. If indeed it's wrong to place such world data there, where is the best place?

    I know this is super newbie question, but I am learning piece by piece and obviously would prefer to follow good practices as much as possible from the beginning...
     
    Last edited: Mar 30, 2019
  10. taivasltd

    taivasltd

    Joined:
    Mar 27, 2019
    Posts:
    20
    Just read this and wondering if Resources is the right place for my questions above?
    https://docs.unity3d.com/Manual/SpecialFolders.html


    EDIT:
    Ok I actually changed that, recreated the paths under Resources and used .Load to load the file to a text asset.
    Overall seems to work exactly the same but also in the build you can't see these files :) Great!
     
    Last edited: Mar 30, 2019
  11. joaobsneto

    joaobsneto

    Joined:
    Dec 10, 2009
    Posts:
    152