Announcement

Collapse
No announcement yet.

How to organize specialized data, since structs cannot be generalized?

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

    How to organize specialized data, since structs cannot be generalized?

    With the „Advanced Mission And Notification System V3" being free for the month in June 2019, I digged around the source files there and saw something that kinda shocked me. I am rather new to working with the Unreal Engine and there I stumbled upon something that I cannot quite solve by myself, concerning organizing specialized data.

    Here is a simple example. In a game, you have missions, every missions has objectives. An objective could be to reach a certain actor, to collect something, to interact with something, you get the idea. Objectives and missions themselves are pure data, so an obvious approach would be to create structs that describe these object types. There could be an BPS_InteractObjective, a BPS_ReachObjective and so on.

    At this point, you might already see something. Objectives, being pure data, share stuff, in theory. Every objective could have a description, could be colored in some way and so on. Fine, since structs do not support inheritance or interfaces, we could create something like BPS_ObjectiveDisplayInformation and add it to every struct that describes an objective. Bullet dodged.

    Nonetheless, we will reach a point where we would need generalization. Mission have objectives, but what now? We have different structs for every type of objective that have nothing in common. How could we add these to a mission, which is also a struct? „Advanced Mission And Notification System V3" solves this by creating a struct that holds an array of every single objective type with an enumeration that determinates which objective type sohuld be used, however, this is incredibly inefficient, isn't it, because you would allocate memory for every single objective type although only one, which is decided by the enumeration value, is actually used.

    However, how would you solve this? I cannot think of any way to create different types of objectives as structs without having to use something like their solution. Around reddit, I saw someone suggesting using classes with an interface for IObjective or something, but classes for pure data loaded from a data table?

    Another idea that I have are Actor Components. One Actor which represents and handles missions and then dropping Actor Components which represent objectives in there. Would this be a good idea?
    Last edited by Ardenian; 06-03-2019, 08:46 AM.

    #2
    I mean, what confused me so much, any system that is data-driven, be it condition, validation, requirement or whatever, any of these wouldn't be possible without some really nasty solutions as pointed out before in my inital post. In Unity, I would use ScriptableObject for that, which allows to store and manipulate data without requiring an object in the world and does allow interfaces and inheritance, therefore I went for structures in the Unreal Engine 4, but here they seperate so much between data and actors that you are almost unable to link data and data manipulation together.

    It drives me crazy because it feels as if I don't see one important detail or feature that allowed me to easily solve my issue.

    Comment

    Working...
    X