目的:使用C++绑定GameMode参数
使用C++代码设置GameMode 的 Pawn,HUD,PlayerController,GameState,PlayerState,效果参照下图。
蓝图设置GameMode
C++代码设置GameMode
创建C++类
分别以下面的基类创建对应的子类
GameModeBase,Pawn ,HUD,PlayerController,GameStateBase ,PlayerState ,SpectatorPawn ,GameInstace
绑定C++类
在C++ TestGameMode 类构造函数中设置对应参数
// TestGameGameMode 构造函数中设置对应的 GameMode 的参数,当然要先引入下面对应类的头文件
ATestGameGameMode::ATestGameGameMode()
{
GameStateClass = ATestGameState::StaticClass();
PlayerControllerClass = ATestPlayerController::StaticClass();
PlayerStateClass = ATestPlayerState::StaticClass();
HUDClass = ATestHUD::StaticClass();
DefaultPawnClass = ATestPawn::StaticClass();
SpectatorClass = ATest_SpectatorPawn::StaticClass();
}