Sign in to follow this  
rogerdv

Unity Best way to store NPC definitions

Recommended Posts

Im currently Im using xml files containing the required info: stats, skills, inventory, etc, which are parsed on Start(). The method works, but I would like to know if Unity has some better way more artist friendly or integrated into the editor, to achieve the same result.

Share this post


Link to post
Share on other sites

Im currently Im using xml files containing the required info: stats, skills, inventory, etc, which are parsed on Start(). The method works, but I would like to know if Unity has some better way more artist friendly or integrated into the editor, to achieve the same result.

 

What does the storage type have to do with editor or being artist friendly? You will *always* have to store your information in some sort of file system, be it binary, textual, be it xml, json or yaml.

 

You build your editor on top of that - you will just parse your files on loadup like normal, then you have editing tools that work on the generated entities (or some specific editor abstraction so you don't have to build in things like dynamic reload that you don't need in a regular game), and when saving, you serialize the entities to whatever target file format you choose.

 

If that didn't answer your question please rephrase it or give a more detailed explanation of what you exactly want to know.

 

EDIT: Uh, just nevermind, I didn't read in the title/realise that this thread is actually about data storage in unity, apologies.

Edited by Juliean

Share this post


Link to post
Share on other sites

No, Unity doesn't really offer much when it comes to data storage. I would argue that you want to keep it in some sort of external format such as XML so that you can make quick changes outside of the editor. But if you really wanted to keep it in the editor, this data could just be public variables on any sort of GameObject, which you'd edit in the inspector like any other. But there are many downsides - renaming fields may destroy the data, the data has to be in a type that C# can serialise (or you write a custom serialiser for it), adding and removing entries in a list is awkward, etc.

 

But, if you really want to be 'artist friendly' then sure, you could insist on having this stuff in the editor. You might want to write some custom inspectors or editor extensions to make it easy. As long as the end result is changing values on game objects that are in the scene, that's much the same as storing it in an external data file.

Share this post


Link to post
Share on other sites

Thanks, I see that Im not so wrong in my approach. I wanted to confirm that there is no other better way, because I thought that asset files and ScriptableObject could be a way to store the info, and let the artist change the stored values directly in the editor, instead of editing an xml file.

Seems that if I want something more friendly Ill have to write my own editor extensions.

Share this post


Link to post
Share on other sites

The ScriptableObject method will work, if you just want a serialisable lump of data that you can tweak in the editor. That makes it easy to edit simple values, but you still need to write the tooling for more complex edits. (Admittedly easier inside Unity than outside, usually.) I just find that I don't always want my data so tightly joined to Unity and in a form that can't be opened by a text editor or other tool.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Announcements

  • Forum Statistics

    • Total Topics
      628359
    • Total Posts
      2982259
  • Similar Content

    • By koto
      Hello,

      I'm developing a roguelike game. Currently it's in a playable state and I think it's a high time to show it and hopefully get some feedback.

      The game has following features:
      - turn based
      - procedurally generated levels
      - tons of loot
      - spells system
      - trading system
      - some quests
      - some limited crafting
      - door/key/lever mechanics
      - quite a lot of different (look/behaviour) monsters

      Trailer:
      Demo: http://kotogames.com/wp-content/uploads/2017/11/OuaD_demo.zip
      Regards,
      Tom
       
    • By Afambus
      Hello,
      I have a full experienced team that looking for a composer and another 3d designer, im expecting as much from you there are other people in this server that can help you we have a determined team, we have done many things in our game there is more information in the discord about everyone and there skills there region and about the game, if you join the discord pm asap
      https://discord.gg/b2teN3m
    • By BAG Labs
      Mobile SoS

      Platform: Android
      Genre: Board
      Link: Google Play
       
      This games sharpen memory and test your strategies to place S-O-S pattern within time limit and serve 3 difficulties as Easy, Normal, and Hard.

      Goals of the game is to put S-O-S words in patterns (Horizontal, Vertical, and Diagonal) alternately with enemy.
       
      Features:
      Single Player Multiplayer Achievements Leaderboards  
       
      Screenshot:

       

       

       
      Link: Google Play
       
      Please help us improve this game with review
    • By abarnes
      Hello!
      I am a game development student in my second year of a three year program and I would like to start building my portfolio. I was thinking of creating some games to show what I can do to potential employers since I wont have any work related experience when I graduate. But as I'm sure you all know there are tons of ways to approach developing/designing a game and I'm curious if anyone had any insight as to any "standards" that come with this? Is it okay to use game engines like Unity, Unreal, Game Maker etc? Or would it be better to make a game from scratch to better show case your skills? Any and all advice will be greatly appreciated!
    • By Hilster
      Hello 2D Artists,
      I've started making a 2D Puzzle Adventure game for mobile and I'm looking for someone who would want in on creating assets for the game. The core of the programming is pretty much complete, you can walk within the grid laid out and push boxes, when there is an object on top of a pressure pad it will activate the linked objects or if there is one object with multiple linked pressure pads it requires you to activate all points for the object to become active. 

      The level iteration for the game is quick and simple, a Photoshop file that is made of individual pixels that represents objects is put into the game and it creates the level out of those pixels with the assigned objects.
      The objects that need sprites created so far is the character, box, pressure pad, door, trap door, the walls, the stairs and the tiled background.
      I intend to add more objects so the amount I'd like to add will be extended.
      My motivations for posting here is to have something that looks nice to be able to display on my portfolio, so if you're looking for a working game that you can place your art into and improve the look of your portfolio then we're in business.
      Please reply with a few past examples of your art below and I'll be in touch!
  • Popular Now