How to create custom config files?

I want to create some custom config files so that I can load in config information and assets for my classes. An example name: “MyGameWeapons.ini”

Is there a way to do this?

Disclaimer: I haven’t tried this in UE4 yet, but according to the documentation this works the same as in UE3.

In your Weapon class’ header file, add Config=MyGameWeapons in the UCLASS() declaration.

UCLASS(Config=Game)
class AExampleClass : public AActor    

All configurable properties declared in that class (and any derived classes) will then read their values from Config/DefaultMyGameWeapons.ini. You’ll have to create the file yourself, I think.

Ah I see. This is useful to know.

However this method does not work with USTRUCTs unfortunately, and I can’t make the struct a class without inheriting something.

I guess it’s back to the drawing board for me, thanks for the help.

I don’t understand. A struct is basically just another variable type. If you’ve got a variable of type, say, WeaponStruct that variable could have a config specifier. You can then define the contents of the struct variable for each class inheriting from this base class.

Or are you trying something else?

An alternative way to do data-driven development is using data tables: Data Driven Gameplay Elements in Unreal Engine | Unreal Engine 5.2 Documentation

I’m sorry, what I meant is that USTRUCT(Config=MyGameWeapons) is not valid whereas UCLASS(Config=MyGameWeapons) is valid. It is also not possible to declare a UCLASS() without inheriting the class from a UE4 class like UObject.

I will look into the Data Tables, at a glance they look to be very close to what I would like to do.

Essentially, I want to keep the config data in an array or some other container that can be accessed on weapon creation to bring all the weapon stats and assets together.