Files
loneseDocument/Content/Blueprints/BP_CameraPawn.md
meishibiezb 29a3f77908 init
2026-06-04 21:44:13 +08:00

53 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# BP_CameraPawn
## 基本信息
- **类型**: Blueprint (Pawn)
- **父类**: ACameraPawn
- **源文件**: /Game/Blueprints/BP_CameraPawn.BP_CameraPawn
- **模块**: Content
## 功能概述
BP_CameraPawn 是分离式第三人称摄像机的蓝图实现,继承 C++ 的 ACameraPawn。在蓝图层面配置摄像机参数初始旋转、臂长范围、速度等并提供编辑器内可视化调整能力。
## 设计用意
ACameraPawn 在 C++ 层提供了完整的 SpringArm+Camera 组件和缩放、旋转、移动、重置逻辑。BP_CameraPawn 作为蓝图配置层,将摄像机的默认参数(初始旋转 -60 度、初始臂长 1200、臂长范围 300-3000、旋转速度 2.0、缩放速度 10.0、移动速度 10.0、移动限制 800暴露在蓝图中方便在编辑器内调整和迭代。
## 职责范围
BP_CameraPawn 负责摄像机参数的蓝图级配置和编辑器内可视化调整。底层的摄像机变换逻辑SpringArm 的臂长插值、旋转计算、移动偏移等)全部由 ACameraPawn C++ 层处理。
## 项目内依赖
| 依赖项 | 关系 | 源文件 |
|--------|------|--------|
| ACameraPawn | 父类 | C++ 源码 |
## 对外接口
- **继承自 ACameraPawn 的 BlueprintCallable 函数**
- `CameraZoom(const FInputActionValue& Value)` -- 摄像机缩放,调整 SpringArm 臂长
- `CameraRotate(const FInputActionValue& Value)` -- 摄像机旋转,调整 SpringArm 的旋转偏移
- `CameraMove(const FInputActionValue& Value)` -- 摄像机平移,调整 SpringArm 的 SocketOffset
- `CameraReset(const FInputActionValue& Value)` -- 重置摄像机到默认位置和旋转
- **继承自 ACameraPawn 的 BlueprintReadOnly 属性**
- `SpringArmComponent` (USpringArmComponent*) -- SpringArm 组件引用
- `CameraComponent` (UCameraComponent*) -- Camera 组件引用
- `FollowTarget` (APawn*) -- 跟随目标 PawnVisibleInstanceOnly
- **蓝图可调的配置参数**EditDefaultsOnly, BlueprintReadOnly
- `InitialRotation` = FRotator(-60, 0, 0) -- 初始俯仰角
- `InitialArmLength` = 1200.0f -- 初始臂长
- `RotateSpeed` = 2.0f -- 旋转速度
- `ZoomSpeed` = 10.0f -- 缩放速度
- `MoveSpeed` = 10.0f -- 平移速度
- `MaxArmLength` = 3000.0f / `MinArmLength` = 300.0f -- 臂长范围
- `CameraMoveClamp` = 800.0 -- 平移限制范围
## 使用方法
- 通过 BP_TestChar (AMyCharacter) 的 `CameraActorClass` 属性配置,角色 Possess 时自动生成摄像机实例
- 继承自 ACameraPawnC++ 层提供了完整的 SpringArm+Camera 组件和变换逻辑
- 蓝图层面可在 EventGraph 中响应事件event_count=3node_count=3
- 配置参数均为 `EditDefaultsOnly`,在蓝图类默认值中调整摄像机行为,无需修改 C++ 代码
- ACameraPawn 的 Tick() 处理每帧的臂长插值、旋转跟随和移动偏移,蓝图不参与底层变换
- `FollowTarget` 在运行时由 SetFollowTarget 逻辑自动设置为当前控制的角色
## 用例
- BP_TestChar (AMyCharacter) 中 `CameraActorClass` 属性引用,作为角色的分离式摄像机
- 被 Possess 角色时自动生成,跟随 `FollowTarget` Pawn