2.6 KiB
2.6 KiB
BP_TestMode
基本信息
- 类型: Blueprint (GameMode)
- 父类: GameModeBase
- 源文件: /Game/Blueprints/BP_TestMode.BP_TestMode
- 模块: Content/Blueprints
功能概述
BP_TestMode 是项目的 GameMode 蓝图,配置默认的 Pawn、PlayerController 和 HUD 类,将项目的所有核心类串联起来。
设计用意
作为项目唯一的 GameMode,BP_TestMode 将分散的蓝图类通过引擎框架连接在一起。它将 BP_TestChar 设为默认 Pawn、BP_TestCtl 设为玩家控制器、BP_Hud 设为 HUD 类,形成一个完整的游戏运行时配置。这样所有核心类型的替换只需要修改这一个地方。
职责范围
BP_TestMode 负责配置默认游戏类和串联项目核心类型之间的关系。具体的角色行为、控制器逻辑、UI 管理分别由各自对应的类负责。
项目内依赖
| 依赖项 | 关系 | 源文件 |
|---|---|---|
| BP_TestChar | DefaultPawn | /Game/Blueprints/BP_TestChar |
| BP_TestCtl | PlayerController | /Game/Blueprints/BP_TestCtl |
| BP_Hud | HUD | /Game/Blueprints/BP_Hud |
外部视角
BP_TestMode 是 GameModeBase 的蓝图子类,从外部调用者视角:
核心配置(Class Defaults 中设置)
DefaultPawnClass= BP_TestChar — 玩家生成时使用的默认 PawnPlayerControllerClass= BP_TestCtl — 玩家控制器类HUDClass= BP_Hud — 游戏 HUD 类
EventGraph 事件
| 事件 | 类型 | 触发时机 | 行为 |
|---|---|---|---|
事件开始运行 |
原生覆盖 (BeginPlay) | GameMode 创建时由引擎自动触发 | 预留(当前无连线逻辑) |
事件Tick |
原生覆盖 | 每帧 | 预留(当前无连线逻辑) |
无自定义公开接口 BP_TestMode 不添加自定义函数或变量,所有行为通过引擎框架的 GameMode 生命周期事件驱动。
外部交互方式
- 关卡地图在 World Settings 中选择 BP_TestMode 作为默认 GameMode
- 引擎在游戏启动时自动读取其 Class Defaults 配置并实例化引用类
使用方法
BP_TestMode 在项目中的典型调用流程:
- 游戏启动流程 — 关卡(Map_City/Playground)在 World Settings 中引用 BP_TestMode → 引擎读取 Class Defaults → 自动创建 BP_TestChar(DefaultPawn)、BP_TestCtl(PlayerController)、BP_Hud(HUDClass)→ 三者自动配对
用例
| 引用方 | 路径 | 用途 |
|---|---|---|
| Map_City | /Game/地图关卡/Map_City |
设为关卡的默认 GameMode,驱动该地图运行时配置 |
| Playground | /Game/地图关卡/Playground |
设为关卡的默认 GameMode,驱动该地图运行时配置 |