Best practise for assigning DefaultPawn to a GameMode?

So, they’re problems with all approaches I’ve come accross.

I could create a pure C++ *ACharacter *and reference the class by DefaultPawn = AMyCharacterClass::StaticClass(), however, now I cannot tweak the characters variables outside of code …

I could also create a pure BP-Class and reference it like this: static ConstructorHelpers::FClassFinder<ACharacter> MyBluerintClass(TEXT("\Game\MyBlueprintClass")), and then assigning it’s class value to the default pawn: DefaultPawn = MyBlueprintClass.Class. Works wonders, except for one reason, I now have the character logic in a blueprint class (which you can have, but I’m a programmer, not using BP for anything else than light gameplay scripting), also, I have to hard reference it with a string, so it’ll break if I move the Blueprint asset.

Last option as far as I know is to create a *ACharacter *class to hold all the logic, and create a BP inherited from my *AMyCustomCharacter *class and use that BP-Class as my DefaultPawn, now I have all the logic in my C++ class, however, it still requiers a hard reference using a string, which honestly makes me want to lightly pinch myself in the arm.

TLDR: In your experience, what’s the best way to assign a DefaultPawn to a C++ GameMode to counter these issues:

  • Tweakable variables
  • No hard string references

I don’t understand your dislike to the string reference. Most people that I know use your last option, a C++ base class and then a blueprint version for ease of customization. In fact, I typically have all of my logic in C++ but spawn/work with the blueprint version for everything (pawns, weapons, projectiles, etc). What issue are you running in to?

Well, it’s a hard reference, if I move the blueprint asset, then I’ll have to alter the string. And if my designer or artist changes the asset location, the game breaks, that’s not very good, not good at all. However, I found a solution, if I convert my C++ GameMode to a BP, which I only use for references between the editor and C++, I can still cast to my C++ cast when accessing the GameMode, since it holds all logic, literally 100% of it.

So I can just reference the Blueprint asset in the GameMode blueprint and still have a c++ class to cast to when accessing my game mode through code.