Skip to content

RootMotion(服务端权威)

RootMotion 是由动画驱动位移的机制。Behemiron 的 RootMotion:

  • 在服务端计算(权威)
  • 客户端负责播放动画与视觉同步

1. 基础规则

  • RootMotion 只读取 Graph 中 clips 段。
  • 每个 clip 必须写 length(秒)。
  • 位移单位:模型单位(1 方块 = 16)。
  • 旋转单位:角度(yaw)。

2. 开启 RootMotion

bindings 中打开:

yml
flags:
  applyRootMotion: true

3. RootMotion 模式

3.1 速度驱动(velocity)

yml
rootMotion:
  mode: velocity
  velocity: [0, 0, 1.2]
  yawSpeed: 0
  • velocity 单位:模型单位/秒
  • yawSpeed:度/秒

3.2 曲线驱动(curve)

yml
rootMotion:
  mode: curve
  curve:
    - {t: 0.0, pos: [0, 0, 0]}
    - {t: 0.2, pos: [0, 0, 8]}
    - {t: 0.8, pos: [0, 0, 24]}
  yaw:
    - {t: 0.0, yaw: 0}
    - {t: 0.8, yaw: 15}

4. 高级调参(速度/缩放)

这些字段用在 rootMotion 中:

  • speedVar:方块/秒(如 query.ground_speed
  • scaleVar:从 vars 里读取的缩放因子
  • scale:常量缩放
  • minScale / maxScale:缩放范围

示例(RPG 负重 / 冲刺):

yml
rootMotion:
  mode: velocity
  velocity: [0, 0, 1.2]
  speedVar: "query.ground_speed"  # 方块/秒
  scaleVar: "root_scale"          # vars 中的值
  scale: 1.0
  minScale: 0.6
  maxScale: 1.2

5. RootMotion 运行模式(flags)

bindings 中可写:

  • rootMotionMode: override / additive / blend
  • rootMotionWeight: 0~1(blend 权重)
  • rootMotionInterval: 强制更新周期(tick)
  • rootMotionMaxDistance: 超过距离则不更新
  • rootMotionLodNear/Mid/Far: LOD 距离阈值
yml
flags:
  applyRootMotion: true
  rootMotionMode: "blend"
  rootMotionWeight: 0.75
  rootMotionInterval: 1
  rootMotionMaxDistance: 72
  rootMotionLodNear: 32
  rootMotionLodMid: 64
  rootMotionLodFar: 96

6. 状态覆盖(服务端)

服务端不解析 Molang,但可以用变量强制 RootMotion 状态:

yml
vars:
  state: "run"        # 覆盖所有层
  state.base: "run"   # 指定 layer

7. 常见问题

  • RootMotion 没有移动applyRootMotion 未开启或 clip 未配置 length
  • 移动太快/太慢:检查 velocity / scaleVar / speedVar