实现移动平台乘客接口,优化乘客跟随逻辑
This commit is contained in:
29
Assets/_Game/Scripts/Core/IPassengerReceiver.cs
Normal file
29
Assets/_Game/Scripts/Core/IPassengerReceiver.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace BaseGames.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// 移动平台乘客接口。
|
||||
/// 实现此接口的对象可被 <see cref="BaseGames.World.MovingPlatform"/> 携带,
|
||||
/// 无需修改 Transform 父子关系,避免与动画/摄像机/HitBox 系统冲突。
|
||||
///
|
||||
/// 协议(执行顺序保障):
|
||||
/// 1. MovingPlatform.FixedUpdate(-300)计算本帧期望位移 delta → 调用 SetPlatformDelta。
|
||||
/// 2. 实现方 FixedUpdate(-200)最前端消费 delta:_rb.position += delta。
|
||||
/// 3. 乘客离开传感器时 MovingPlatform 调用 OnLeavePlatform,继承平台速度防止卡顿。
|
||||
/// </summary>
|
||||
public interface IPassengerReceiver
|
||||
{
|
||||
/// <summary>
|
||||
/// 由 MovingPlatform 每帧推送本帧平台期望位移量(不依赖 MovePosition 是否已执行)。
|
||||
/// 实现方存入待处理字段,在自己的 FixedUpdate 最前端消费,避免与 velocity 冲突。
|
||||
/// </summary>
|
||||
void SetPlatformDelta(Vector2 delta);
|
||||
|
||||
/// <summary>
|
||||
/// 乘客离开平台时调用,传入平台当前帧速度,由实现方叠加到自身速度。
|
||||
/// 防止离台瞬间速度突变产生卡顿。
|
||||
/// </summary>
|
||||
void OnLeavePlatform(Vector2 platformVelocity);
|
||||
}
|
||||
}
|
||||
11
Assets/_Game/Scripts/Core/IPassengerReceiver.cs.meta
Normal file
11
Assets/_Game/Scripts/Core/IPassengerReceiver.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f719c44d9262914baec9ba887be8c54
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user