Using structs within structs within structs... Not visible in inspector!


I start off with the same disclaimer as my last thread: I am coming from a Unity background and getting used to the Unreal way of thinking so this might be extremely trivial, but I have searched for 2 nights in a row now without any solution.

On to the problem:

I want to create a nice organized structure for my character/enemy/whatever attributes and the way that was done in Unity was creating classes without inheritance and used them as “folders” pretty much. E.g. a class was created called “Weapons” which in turn had GameObject gun1, GameObject gun2 etc… Then on my character I added a Weapon class instance and dragged prefabs into place in gun1, gun2 etc.

I started off with that approach in Unreal but it seems that I am better of using structs (or USTRUCTS rather perhaps), using classes seemed tedious since each time you had a class within another class you had to use CreateDefaultSubobject and I could never get the properties do display nicely in the inspector. So I chnaged it all to structs and now it kind of works. I have a struct called Health which contains floats fro my head, left arm, right arm etc. Then I add property to my character (or any other actor) and all values are displayed and editable in the inspector, great!

Now I want something a bit more advanced, in this case armor. I want a armor struct which contains armor pieces (one for each part) and each armor part has a values for piercing bullets, explosives, fire etc. Each of those values are a simple float. Compile and everything works but in the inspector the Armor struct is visible, the Head, Left Arm etc is visible but the values are blank!!! There is no way of displaying the armor piece properties and this is driving me mad…

And another thing on the same subject (and perhaps partially cause of the problem), in the struct wiki help (A new, community-hosted Unreal Engine Wiki - Announcements and Releases - Unreal Engine Forums) it is stated that each struct that is going to need another struct within itself needs to have the included struct in the same file above the struct, is this really necessary? Can’t one use headers as normal? If this is the case things will become messy real fast and it probably will force me back to Unity… Some structs I have will be used in several other structs and (for example damage and armor will have corresponding values, piercing, fire etc) and I do not want to have all of these in the same file, it is just very impractical and sloppy.

And will someone please explain why one should not use a class in these cases?

Thank you!

It all got sorted out somehow, I think there was some issues with hot-reloading, once closing everything down and compiling in VS it magically worked. Well that was 3 nights wasted but lesson learned :slight_smile: