Files
ggj26_heron/Docs/PenguinAbility使用说明.md

187 lines
5.3 KiB
Markdown
Raw Permalink 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.
# PenguinAbility企鹅能力使用说明
## 功能概述
PenguinAbility 是专为企鹅Penguin设计的能力系统使其能够在冰面上滑行加速。
## 核心功能
### 1. 冰面滑行
- **企鹅在冰面上加速**:移动速度提升至 1.5 倍
- **更低的摩擦力**:让企鹅在冰面上滑得更远
- **自动调整移动参数**:进入冰面时自动调整速度和摩擦力
- **自动恢复参数**:离开冰面时恢复原始移动参数
### 2. 可调整的冰面参数
#### IceSpeedMultiplier冰面速度倍率
- **默认值**1.5150%的正常速度)
- **作用**:控制在冰面上的移动速度
- **调整建议**
- 1.2 - 轻微加速
- 1.5 - 默认,明显加速
- 2.0 - 极速滑行
- 2.5 - 超高速(谨慎使用)
#### IceGroundFriction冰面摩擦力
- **默认值**0.5(低摩擦力,更滑)
- **作用**:控制在冰面上停止移动的速度
- **调整建议**
- 0.2 - 极滑,很难停下
- 0.5 - 默认,冰面滑行感
- 1.0 - 轻度滑行
- 2.0 - 接近正常摩擦
## 使用方法
### 在蓝图中调整参数
1. 打开 `BP_HeronPlayerState` 蓝图(或你的 PlayerState 蓝图)
2. 在 Details 面板中找到 `Penguin Ability Class`
3. 如果需要自定义参数:
- 创建一个继承自 `PenguinAbility` 的蓝图类BP_PenguinAbility
- 在蓝图中调整 `Ice Speed Multiplier``Ice Ground Friction`
-`BP_HeronPlayerState` 中将 `Penguin Ability Class` 设置为你的蓝图类
### 在编辑器中设置冰面
1. 创建一个 Actor 作为冰面(可以使用 Box Trigger 或 Box Collision
2. 在该 Actor 的 Details 面板中找到 **Tags** 部分
3. 添加标签 **"Ice"**
### 在 C++ 中动态调整参数
```cpp
// 获取 PenguinAbility
if (UPenguinAbility* PenguinAbility = Cast<UPenguinAbility>(PlayerState->CurrentAbility)) {
// 动态调整冰面速度
PenguinAbility->IceSpeedMultiplier = 2.0f;
// 如果已经在冰面上,需要重新应用参数
if (PenguinAbility->bIsOnIce) {
PenguinAbility->ExitIce();
PenguinAbility->EnterIce();
}
}
```
## 工作流程
### 进入冰面
1. HeronPlayer 检测到与标签为 "Ice" 的 Actor 碰撞
2. 检查当前能力是否为 Penguin
3. 如果是 Penguin调用 `EnterIce()`
4. PenguinAbility 保存原始移动参数
5. 应用冰面移动参数(速度 × 1.5、降低摩擦力)
### 离开冰面
1. HeronPlayer 检测到离开标签为 "Ice" 的 Actor
2. 调用 PenguinAbility 的 `ExitIce()`
3. 恢复原始移动参数
### 切换能力时在冰面上
- 如果从 Penguin 切换到其他能力且在冰面上,会自动调用 `ExitIce()` 恢复参数
- 其他鸟类在冰面上保持正常移动(不加速)
## 调试建议
### 日志输出
系统会输出以下日志,可在 Output Log 中查看:
- `"PenguinAbility: Entered Penguin ability - Can skate on ice!"` - 切换到企鹅能力
- `"PenguinAbility: Entered ice - Ice skating mode activated!"` - 进入冰面
- `"PenguinAbility: Exited ice - Normal movement restored"` - 离开冰面
### 实时查看参数
在编辑器 Play 模式下:
1. 选中玩家角色
2. 在 Details 面板中找到 `PenguinAbility` 组件
3. 展开 `Penguin|IceSkating` 分类
4. 可以看到 `bIsOnIce` 状态和当前参数
## 与 MallardAbility 的对比
| 特性 | PenguinAbility | MallardAbility |
|------|----------------|----------------|
| 触发标签 | "Ice" | "Water" |
| 速度变化 | 1.5倍加速 | 0.8倍减速 |
| 重力变化 | 无变化 | 降低至0.3 |
| 摩擦力 | 降低至0.5 | 提高至2.0 |
| 非对应能力 | 正常移动 | 死亡 |
## 扩展建议
### 添加冰花特效
`TickComponent` 中添加:
```cpp
if (bIsOnIce) {
// 生成冰花粒子效果
// UGameplayStatics::SpawnEmitterAtLocation(...)
}
```
### 添加滑行动画
`EnterIce()` 中:
```cpp
// 切换到滑行动画
if (ACharacter* Character = Cast<ACharacter>(GetOwner())) {
// 设置滑行动画状态
}
```
### 添加滑行音效
`EnterIce()` 中:
```cpp
// 播放冰面滑行音效
UGameplayStatics::PlaySound2D(this, IceSkatingSound);
```
### 实现冰面转弯困难
可以添加转向速度限制:
```cpp
// 在冰面上降低转向速度
if (bIsOnIce && MovementComp) {
MovementComp->RotationRate = FRotator(0, 180, 0); // 降低转向速度
}
```
## 配合系统
PenguinAbility 与以下系统协同工作:
- **HeronPlayer**:冰面碰撞检测
- **HeronPlayerState**:能力切换管理
- **CharacterMovementComponent**:移动参数调整
## 注意事项
1. 冰面 Actor 必须有 **"Ice"** 标签
2. 参数调整会影响游戏手感,建议多次测试
3. 如果在蓝图中创建子类,确保父类设置正确
4. 切换能力时会自动处理冰面状态,无需手动管理
5. 可以同时有水体和冰面,系统会分别处理不同的标签
## 推荐参数组合
### 快速滑行(竞速风格)
```
IceSpeedMultiplier = 2.0
IceGroundFriction = 0.3
```
### 真实滑冰感
```
IceSpeedMultiplier = 1.5
IceGroundFriction = 0.5
```
### 轻度加速
```
IceSpeedMultiplier = 1.2
IceGroundFriction = 1.0
```
## 已修复的问题
- ✅ 修复了 HeronPlayerState.cpp 中 Penguin case 创建错误类型的 bug
- ✅ 添加了 break 语句防止 switch fallthrough
- ✅ 集成了 PenguinAbility 到 HeronPlayer 的碰撞检测系统