2

I want to change the default pawn of my game and I decided to do it with c++.

I came up with this solution, which works fine:

static ConstructorHelpers::FClassFinder<APawn> MyPawn(TEXT(" address..."));
        DefaultPawnClass=Pawn.Class;

However, I searched on the internet and found this approach used more often:

static ConstructorHelpers::FObjectFinder<UClass> MyPawn(TEXT(" address..."));
        DefaultPawnClass=(UClass*)Pawn.Object;

What advantages does UObjectFinder have over UClassFinder?

Are there certain circumstances where one is preferable to the other?

Saurabh Kumar
  • 145
  • 2
  • 6

1 Answers1

3

FObjectFinder is used to find any UObject. FClassFinder is used to find any UClass. Note that a UClass itself is a UObject, so the object finder is the more general utility.

Since what you are ultimately trying to find here is a class, FClassFinder is the "better" option in the sense that it more clearly communicates your intent, and the result is itself already a TSubclassOf<T>.