RUDPFramework/openspec/changes/separate-simulation-from-pr.../proposal.md

28 lines
1.8 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.

## Why
当前 `MovementComponent` 将模拟层pending inputs 维护、服务器校正、重放和表现层视觉插值、bounded correction耦合在一起。bounded correction 的收敛目标是实时变化的 server position导致客户端永远在追赶——每次收到服务器状态收敛目标就变了。表现为本地移动平滑加上网络同步后抖动。
## What Changes
- **新增** `LocalPlayerPresentationState` 类型:持有 `_currentPosition/Rotation`(当前显示)和 `_targetPosition/Rotation`(模拟层给的目标)
- **新增** `LocalPlayerSimulationState` 类型:持有 `_lastAuthoritativePosition/Rotation`、`_pendingInputs`、`_presentationTarget`
- **重构** `MovementComponent``OnAuthoritativeState` 只更新 `_presentationTarget`,不直接修改 rigid.position
- **重构** 表现层:每帧用 Lerp 将 `_currentPosition` 插值到 `_targetPosition`,再设置 rigid.position
- **移除** `ControlledPlayerCorrection` 相关逻辑bounded correction 被表现层 Lerp 替代
## Capabilities
### New Capabilities
- `local-player-presentation-state`: 表现层状态current/target position & rotation及每帧插值更新
- `local-player-simulation-state`: 模拟层状态authoritative baseline、pending inputs、presentation target
### Modified Capabilities
- `local-player-reconciliation`: 模拟层收到服务器状态后计算 PresentationTarget表现层负责插值收敛不再使用 bounded correction
## Impact
- 新增 `Assets/Scripts/Network/NetworkApplication/LocalPlayerPresentationState.cs`
- 新增 `Assets/Scripts/Network/NetworkApplication/LocalPlayerSimulationState.cs`
- 修改 `Assets/Scripts/MovementComponent.cs`
- 删除 `Assets/Scripts/ControlledPlayerCorrection.cs`(或保留作他用)