Download

Strings and USTRUCT

Hey all,

Trying to use a USTRUCT. It seems fine for variables, except when I try to use a FString, FName or Char. Does anyone know if I’m just missing something?

It doesn’t cause a crash, it just gives the error saying it expects a “;”, other variables are working properly.


USTRUCT()
struct FBodyInformation
{
	GENERATED_USTRUCT_BODY()

	UPROPERTY()
		FName limbName; //Says it is expecting ";" here when using FName or FString
	UPROPERTY()
		uint32 limbHealth;
	UPROPERTY()
		uint32 attackType;

};

Thanks!

Try initializing those properties from the ctor. Just add the following into the struct:


#if CPP
        FBodyInformation() :
                limbName(NAME_None)
        {}
#endif

That should do the trick ^^

Hey, thanks for the suggestion. Just got back into the office today to try it but it turns out when adding a Struct I can’t just Compile from within the editor, I have to close the editor and re-compile through Visual Studio.

Yes that is correct, some changes require the editor to fully reload. Those are normally related to types and properties.