Mastering Unreal Engine 4.X
上QQ阅读APP看书,第一时间看更新

Adding the blueprint to the GameMode

Once everything is in place, all that we need now is to make sure that the GameMode class for the game (or for this level) is going to load our Gladiator blueprint by default once the game starts.

Open the Visual Studio project again, go to the BellzGameMode source file, and add this piece of code inside its constructor, in order to set the DefaultPawnClass by defining which blueprint is to be used by specifying its name and path within the project.

static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass(TEXT("/Game/Blueprints/GladiatorCharacter"));
  if (PlayerPawnBPClass.Class != NULL)
  {
    DefaultPawnClass = PlayerPawnBPClass.Class;
  }

And now, if you start an empty level with the basic elements, or even one of the free asset levels, you'll have the Gladiator fully interactive inside the level.