Hi, i want to use The StaticLoadClass function to keep the class in a variable for later use. The problem is, i have no idea how the paths work in unreal engine. This is what i have written, and it throws the error
CharacterClass = StaticLoadClass(UObject::StaticClass(), nullptr, TEXT("/Game/Attrition/Character/AttritionCharacter.AttritionCharacter_C"));
if(!CharacterClass) UE_LOG(LogTemp, Error, TEXT("%s() Failed to find CharacterClass - if it was moved, please update the reference location in C++"), *FString(__FUNCTION__));
The project’s name is attrition and this is the folder where te character class is located:
StaticLoadClass is for loading assets (ie blueprints), not C++ classes. If you’ve got a C++ class you want to reference that way you just need to do AAttritionCharacter::StaticClass( ).
It’s also worth mentioning that doing this sort of thing to load assets is generally bad practice since those hard-coded strings are difficult to keep updated if/when they’re moved around (hence the text of that log message).
It’s usually better to have a TSubclassOf or TSoftClassPtr that you assign in a blueprint or someplace else in the editor.