unreal engine 5.2 c++ 自定义gameplay
发布时间 2023-06-23 15:07:48作者: BuzzWeek
1. 新建c++工程

2. 打开world setting

3. 修改默认GamePlay

4. 依次新建对应GamePlay替换默认GamePlay

Default Pawn

HUD

PlayerController

GameState

PlayerState

SpectatorPawn

5. 添加AhellogpGameModeBase默认构造函数

#include "hellogpGameModeBase.h"
#include "HelloGameStateBase.h"
#include "HelloPlayerController.h"
#include "HelloPlayerState.h"
#include "HelloHUD.h"
#include "HelloPawn.h"
#include "HelloSpectatorPawn.h"
AhellogpGameModeBase::AhellogpGameModeBase()
{
GameStateClass = AHelloGameStateBase::StaticClass();
PlayerControllerClass = AHelloPlayerController::StaticClass();
PlayerStateClass = AHelloPlayerState::StaticClass();
HUDClass = AHelloHUD::StaticClass();
DefaultPawnClass = AHelloPawn::StaticClass();
SpectatorClass = AHelloSpectatorPawn::StaticClass();
}
6. 编译看效果
