Convert a string to Character Class Reference

Inside the database I’m storing player selected character as a string. But then I need a way to turn that string into a Character Class Reference.

How can I achieve this? Before sending the string to the DB, what should I get from the Character Class Reference to make a string and then back to class reference when I need it later?

I really hope that there is a way, and I don’t have to use Get Class Display Name to store that in the DB, and then in game to make a switch on that string and return the needed/equivalent Character Class Reference.

Answer:

Get class path in blueprints :

Or C++ :

Character->GetClass()->GetPathName();

Load class from string via a soft class path/reference :

UClass* Class = FSoftClassPath("/Game/BP_Character.BP_Character_C").TryLoadClass<ACharacter>();
2 Likes

Thanks! I didn’t knew why I couldn’t accept it, but I posted it in Discussions and not Q&A. :smile: