update
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
# BP_TestChar
|
||||
|
||||
## 基本信息
|
||||
- **类型**: Blueprint (Actor)
|
||||
- **类型**: Blueprint (Character)
|
||||
- **父类**: AMyCharacter
|
||||
- **源文件**: /Game/Blueprints/BP_TestChar.BP_TestChar
|
||||
- **模块**: Content
|
||||
- **模块**: Content/Blueprints
|
||||
|
||||
## 功能概述
|
||||
BP_TestChar 是玩家主角的蓝图实现,继承 C++ 的 AMyCharacter。它通过添加 CharacterControl 插件的路由组件来扩展角色能力,在蓝图层面组合移动、指令路由和摄像机控制。
|
||||
@@ -18,7 +18,7 @@ BP_TestChar 是角色的蓝图配置层,负责添加并配置 CharacterControl
|
||||
## 项目内依赖
|
||||
| 依赖项 | 关系 | 源文件 |
|
||||
|--------|------|--------|
|
||||
| AMyCharacter | 父类 | /Game/Blueprints/BP_TestChar (C++ 继承) |
|
||||
| AMyCharacter | 父类 | Source/lonese/MyCharacter.h |
|
||||
| ACameraPawn | 间接(CameraActorClass) | /Game/Blueprints/BP_CameraPawn |
|
||||
| UCommandRouterComponent | 组件 | CharacterControl 插件 |
|
||||
| BP_UniversalEndpointComp | 组件 | /Game/Blueprints/Component/BP_UniversalEndpointComp |
|
||||
@@ -26,32 +26,43 @@ BP_TestChar 是角色的蓝图配置层,负责添加并配置 CharacterControl
|
||||
| BP_ControllerComp | 组件 | /Game/Blueprints/Component/BP_ControllerComp |
|
||||
| BP_SayHello | 组件 | /Game/Blueprints/Component/BP_SayHello |
|
||||
|
||||
## 对外接口
|
||||
- **继承自 AMyCharacter 的 BlueprintCallable 函数**:
|
||||
- `Move(const FInputActionValue& Value)` -- 移动输入处理,供 EnhancedInput 绑定调用
|
||||
- `BeginRun(const FInputActionValue& Value)` / `StopRun(const FInputActionValue& Value)` -- 奔跑切换
|
||||
- `BeginCrouch(const FInputActionValue& Value)` / `StopCrouch(const FInputActionValue& Value)` -- 蹲伏切换
|
||||
- `IsRunning() const` / `IsCrouching() const` -- 状态查询
|
||||
- **继承自 AMyCharacter 的 BlueprintReadOnly 属性**:
|
||||
- `DefaultMapping` (UInputMappingContext*) -- 默认输入映射上下文
|
||||
- `MoveAction`, `RunAction`, `CrouchAction`, `CameraMoveAction`, `CameraZoomAction`, `CameraResetAction`, `CameraRotateAction` -- 各输入动作引用
|
||||
- `CameraActorClass` (TSubclassOf<ACameraPawn>) -- 摄像机 Pawn 类,设置为 BP_CameraPawn
|
||||
- **身上的组件作为对外能力**:
|
||||
- `UCommandRouterComponent` -- 指令路由中心,通过 RegisterEndpoint / InputCommand 接收和分发指令
|
||||
- `BP_UniversalEndpointComp` -- 通用端点,对外暴露 `CommandReceivedDispatcher` 动态多播委托
|
||||
- `BP_MoveInput` -- 移动端点,对外暴露 `CharMove` (CharacterMovementComponent*) 变量
|
||||
- `BP_ControllerComp` -- 摄像机控制端点,对外暴露 `MoveController`、`RotateController`、`ZoomCamera`、`ResetControllerLocation`、`TickFollowChar` 函数及摄像机配置参数
|
||||
- `BP_SayHello` -- 测试端点,验证指令路由系统
|
||||
## 外部视角
|
||||
|
||||
BP_TestChar 是 AMyCharacter 的蓝图子类,从外部调用者视角:
|
||||
|
||||
**继承自 AMyCharacter 的配置属性(BlueprintReadOnly)**
|
||||
- `DefaultMapping`(UInputMappingContext*)— 默认输入映射上下文
|
||||
- `MoveAction` / `RunAction` / `CrouchAction` / `CameraMoveAction` / `CameraZoomAction` / `CameraResetAction` / `CameraRotateAction`(UInputAction*)— 各输入动作
|
||||
- `CameraActorClass`(TSubclassOf<ACameraPawn>)— 分离式摄像机类
|
||||
|
||||
**继承自 AMyCharacter 的操作函数(蓝图可调用)**
|
||||
- `Move(FInputActionValue)` — 移动输入处理
|
||||
- `BeginRun` / `StopRun(FInputActionValue)` — 跑步状态切换
|
||||
- `BeginCrouch` / `StopCrouch(FInputActionValue)` — 蹲伏状态切换
|
||||
- `IsRunning()` / `IsCrouching()`(返回 bool)— 状态查询函数
|
||||
|
||||
**BP_TestChar 新增**
|
||||
- 无自定义变量或公开函数。所有扩展能力通过组件化实现:4 个端点组件(UniversalEndpointComp/MoveInput/ControllerComp/SayHello)+ 1 个 UCommandRouterComponent
|
||||
- CameraActorClass 在 Class Defaults 中设为 BP_CameraPawn
|
||||
|
||||
**EventGraph 事件**
|
||||
|
||||
| 事件 | 类型 | 触发时机 | 行为 |
|
||||
|------|------|----------|------|
|
||||
| `事件开始运行` | 原生覆盖 (BeginPlay) | 角色生成时由引擎自动触发 | 预留(当前无连线逻辑) |
|
||||
| `事件Actor开始重叠` | 原生覆盖 (OnActorBeginOverlap) | 角色与其他 Actor 碰撞时 | 预留(当前无连线逻辑) |
|
||||
| `事件Tick` | 原生覆盖 | 每帧 | 预留(当前无连线逻辑) |
|
||||
|
||||
## 使用方法
|
||||
- 在 BP_TestMode 中设置为 `DefaultPawnClass`,作为项目的默认 Pawn
|
||||
- 在蓝图编辑器中添加 CharacterControl 路由和端点组件:`UCommandRouterComponent` 作为指令路由器,`BP_UniversalEndpointComp`、`BP_MoveInput`、`BP_ControllerComp`、`BP_SayHello` 作为各类指令端点
|
||||
- 通过父类 AMyCharacter 的 `CameraActorClass` 属性指定 BP_CameraPawn 作为分离式摄像机
|
||||
- 配置父类的 InputAction 属性(MoveAction、RunAction 等)连接 EnhancedInput 系统
|
||||
- 各端点组件通过 `EndpointState.InterestedTags` 配置关注的 GameplayTag,UCommandRouterComponent 的 `AutoRegisterEndpoints` 在 BeginPlay 时自动注册所有组件上的端点
|
||||
- 指令链路:EnhancedInput -> UCommandInputComponent -> UCommandRouterComponent -> 匹配的端点组件
|
||||
|
||||
BP_TestChar 在项目中的典型调用流程:
|
||||
|
||||
- **游戏初始化流程** — BP_TestMode 将 DefaultPawnClass 设为 BP_TestChar → 引擎在游戏启动时自动生成角色 → 初始化 4 个端点组件 + UCommandRouterComponent → 触发 BeginPlay
|
||||
- **输入处理流程** — 玩家输入 → Enhanced Input 系统 → AMyCharacter::SetupPlayerInputComponent 绑定 Move/BeginRun/StopRun/BeginCrouch/StopCrouch → C++ 层处理移动和状态切换
|
||||
- **指令路由流程** — 外部指令 → UCommandRouterComponent → 路由到对应端点组件(如 BP_ControllerComp 处理摄像机控制、BP_MoveInput 处理移动指令)
|
||||
|
||||
## 用例
|
||||
- BP_TestMode 的 `DefaultPawnClass`,作为玩家进入关卡时的默认角色
|
||||
- 身上挂载的 `BP_UniversalEndpointComp`、`BP_MoveInput`、`BP_ControllerComp`、`BP_SayHello` 作为该角色的指令处理端点
|
||||
- `CameraActorClass` 属性引用 BP_CameraPawn,角色被 Possess 时自动生成摄像机
|
||||
|
||||
| 引用方 | 路径 | 用途 |
|
||||
|--------|------|------|
|
||||
| BP_TestMode | `/Game/Blueprints/BP_TestMode` | 设为 DefaultPawnClass,作为玩家默认角色 |
|
||||
|
||||
Reference in New Issue
Block a user