I’m making a c++ class that inherits from playerstate so that i can make my own blueprint playstates with some modifications. The primary change is that i’m trying to include functionality for character classes (I.E. fighter, barbarian ect.) To do this i’m using a Datatable which holds some of the information for each class to be referenced (Things like how many HP the character should get per level of class and such which may need to be adjusted frequently for balancing). In order to reference my datatable im using:
Where FClassesDT is my datatable and ClassesDTRef is a reference to a UDataTable:
class TOPDOWN_API Class
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Class", meta = (AllowPrivateAccess = "true"))
UDataTable * ClassesDTRef;
Whenever I compile through the editor or whenever VS finishes compiling EU4 crashes with message :
3178] FObjectFinders can't be used outside of constructors to find /Game/DataTables/FClassesDT.FClassesDT
I might be mistaken but Isn’t Class::Class() the default constructor? Am I getting this error because I have children of Class?
class TOPDOWN_API Barbarian : public Class
Any assistance would be appreciated!
EDIT:: The code seems to work as well after the engine is restart. It just crashes when compiling.
UE4 uses C++ in a specific way. To write it properly you must use their architecture. This is why you must inherit your classes from at least UObject class. Also add UCLASS() and GENERATED_BODY() to the class declaration.
I think this might be something like
class TOPDOWN_API UMyClass : public UObject
We can’t name our class “Class”, because UClass is already defined by UE4 and every UObject inherited class must have U at the beginning.
In this constructor you should be able to use FObjectFinders.
I have a new issue relating to the same crashing which is now, in my new playerstate, when i go to instantiate an object that is a child of the UMyClasses object, the engine crashes on compile and on load with:
Assertion failed: [File:D:\Build++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp] [Line: 2498] UObject() constructor called but it’s not the object that’s currently being constructed with NewObject. Maybe you are trying to construct it on the stack, which is not supported.
class TOPDOWN_API AMyPlayerState : public APlayerState
class TOPDOWN_API UBarbarian : public UMyClass