Announcement

Collapse
No announcement yet.

Data Tables, Array of Structs? - Best practice for managing data in a game?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Data Tables, Array of Structs? - Best practice for managing data in a game?

    In a real-time game where the is a large (>100) number of AI actors. Each AI actor has a large (>20) set of constantly changing variables associated with it, representing concepts like health, stamina, speed, morale etc.

    Looking at array of structs, there still appears to be issues, otherwise using them may have been a clear winner.

    What would you suggest as the most efficient/best practice method which will allow us to:

    1. Store and save these variables using the savegame system.

    2. Present this data to the player in the form of table, which is orderable by any one of the variables.

    3. Rapidly access and update this data within the game.

    These concepts are critical to any game which contains a large amount of editable data. Any real-time or turn-based form of strategy, management or builder game has these in common.

    Apologies if it's something which should be obvious - I have sacrificed a lot of time and an untold number of Chrome tabs searching for an answer, so at the very least if we can present a solution here it will be easily retrievable by others who come looking.

    Thanks in advance for any answers!
    My current question - Getting variables from unspawned actorcomponent

    Our game - Robots Minerals Profit! - a side-on builder game with cooperative multiplayer, made in UE4.

    #2
    I'm personally using nested arrays (arrays of structs that are themselves arrays). Like you've mentioned there are still issues with such arrays, but I've found a workaround that works for me until Epic finds an official solution. I've replied to the AnswerHub post you linked to, but I'll post my answer here as well. Depending on what you want to do it might not be the ideal way of doing things

    Originally posted by Monokkel
    I've found a workaround for this. The solution is a bit awkward, but it should do the trick for people like me who have desperate need of nested arrays. The way you do this is to set a temporary variable to your struct array, modify this temporary array and then set this value back into the larger array. Here is how to do it for Set Array Element, though the same principle applies for manipulating the array in other ways. I hope someone will find this helpful until Epic finds an official solution:

    [ATTACH=CONFIG]70649[/ATTACH]
    Attached Files
    The Advanced Turn Based Tile Toolkit (Marketplace page - Feedback thread)

    Comment


      #3
      Thanks for the reply - I really appreciate it.

      As far as making sorted tables is concerned, do you have any recommendation? It seems silly that everyone should have to write functions for "sort this array of structs by the highest/lowest integer" or "get me the top 5 structs by variable X" when they're so universally relevant.
      My current question - Getting variables from unspawned actorcomponent

      Our game - Robots Minerals Profit! - a side-on builder game with cooperative multiplayer, made in UE4.

      Comment


        #4
        The way i do it in my game is mysql database connected through php for dynamically changing data this handles login, inventory, player profiles, user settings etc. Then for what i call constant data i use datatables. Eg things that wont or dont need to change like item names, unit names etc. Then once i get in game i transfer all the data i need for the actual game into arrays or structs so i can alter and change it as needed . Once the game ends or player logs out i call my custom save game/data function/ events which only takes things that have changed in the game and alters the database. The datatables never get altered unless for instance i add a new item, unit, building, spell etc to the game .

        I think rama has made a custom bp node that makes sorting arrays easier in his victory plugin. And ue4 are looking into the bug already. Another future possibility is being able to dynamically alter datatables as i believe hidden in c++ code there are functions to write data but it hasnt been implemented but if i read correctly it has been requested as an engine update and may become.viable in the future unless a forumer figures it out first and posts it up.
        Last edited by EniGmaa; 12-21-2015, 03:51 AM.

        Comment


          #5
          Easiest way is to make struct, then create array out of it. If needed make multiple arrays, then create functions to save, get or add elements.

          But you asked about best way:
          Best way is to make custom blueprint node in C++ that handles it all. Then expose it.

          Comment

          Working...
          X