Set Actor's truct UPROPERTY(config) from .ini

If I have a struct:



USTRUCT()
struct FInstantWeaponData
{
	GENERATED_USTRUCT_BODY()

	/** base weapon spread (degrees) */
	UPROPERTY(EditAnywhere, config)
	float WeaponSpread;

	/** defaults */
	FInstantWeaponData()
	{
		WeaponSpread = 5.0f;
        }
};


and a class:



// A weapon where the damage impact occurs instantly upon firing
UCLASS(Abstract, config = Game)
class AShooterWeapon_Instant : public AShooterWeapon
{
	/** instant weapon config */
	UPROPERTY(EditAnywhere, Category = Config)
	FInstantWeaponData InstantConfig;
};


how can I set the value of WeaponSpread in my DefaultGame.ini



[/Script/ShooterGame.AShooterWeapon_Instant]
WeaponSpread=10.99


This does not seem to have any effect on the WeaponSpread value

Is it possible from DefaultGame.ini to drive the value of a struct variable on an actor like this?

1 Like

First, InstantConfig variable must have the Config specifier.
Second, to initialize properties inside structs use this syntax:



[/Script/ShooterGame.AShooterWeapon_Instant]
InstantConfig=(WeaponSpread=XX)