Search Unity

How to handle game configuration for huge projects

Discussion in 'Scripting' started by Luxgile, Mar 18, 2019.

  1. Luxgile

    Luxgile

    Joined:
    Nov 27, 2016
    Posts:
    16
    Okay so, as the title says i'm working in a huge project with a group of people. So far the workflow was to, for example, make a PlayerMovement that handles the player movement (duh) and a PlayerInput that handles... well, you get the point.

    For us, it was obvious that configuration for, for example, player speed was in PlayerMovement in the Player prefab, as well as enemy life was in the enemy prefab and so on.

    The problem is that, we quickly realised the problem that all the configuration is spreaded all over the project in different prefabs, and for the designers is a pain to find the configuration for X thing without asking whoever made it.

    The only thing we came up with was the obvious step of centralize all configuration to one point so it's easier to balance the game in any way we want, but the problem is i'm not so conviced of this because:

    - Can lead to huge classes with data for everything
    - Every time you want to add more data to a component, you have to modify that centralized place
    - Can lead to duplicated data (From component, and centralized place)
    - It forces components that are completely independent to have dependencies
    I wonder, is there any tool that unity has that i'm not aware of, or some design that could help us?
     
  2. wileyjerkins

    wileyjerkins

    Joined:
    Oct 13, 2017
    Posts:
    77
    I use a hybrid system. Most static stuff is kept on a game controller object (like arrays of gameobjects used to instantiate pooled objects and the pools (aka lists) themselves) and then I use partial classes to define most functions.

    I have a separate player class that sets up the player object, but use a partial class for player input to keep the code separate and tidy.

    I have a separate enemy class that handles enemy AI (where to go, when to shoot, run, hide, define abilities, etc) and health is stored on each instantiated enemy.

    Check out partial classes, it might help you out. I think they are quite handy. I work alone but in a group they would be even handier since they can all reference the same variables.
     
  3. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    The first thing that really helps a lot is to maintain a good asset file structure. This helps a lot when you need to find the prefabs and people know where to look for the components.

    Another important thing to keep in mind is that its often better to seperate data from the consuming behaviour, ScriptableObjects are a good way to achieve that.
    For instance, a monster behaviour could reference an instance of a monster stats type, which you can use in multiple places, even though it'll be maintained in a single place. These scriptable objects can also be linked via the inspector.

    In addition to that, you'll be able to quickly create yet another set of stats and use it for play-testing and balancing, without the need of a duplicate of the whole prefab for backup purposes, but only that one data asset.
     
    lordofduct likes this.
  4. Luxgile

    Luxgile

    Joined:
    Nov 27, 2016
    Posts:
    16
    After a bit of research i think i'll go with a structure similar to partial classes for multiple classes that requires similar data and scriptable objects for global configuration like game difficulty. Thanks for the suggestions!