前言

先占坑 后续补上 ALS 使用基础

UE 动画系统框架介绍及使用 - 知乎

UE4 UE5 骨骼动画 高级运动系统 (ALSV4) - 知乎

【UE教程】从零开始的Lyra动画蓝图制作+解析(简化版)_哔哩哔哩_bilibili

UE 进阶篇一:动画系统_ue distance matching-CSDN博客

前期准备

基础移动

动画蓝图

  • 基础创建

    • 创建ABP_CharacterBase 放入到 BP_Player 中,设置Level的GameMode为 MyGameMode。MyGameMode 的默认Pawn为BP_Player。

    • New State Machine –> Locomotion_SM

      • Inertialization 连接 惯性混合 注:这边先放着
      • 加State : Idel Start Stop Cycle

状态机条件:

重载函数

BlueprintThreadSafeUpdateAnimation 蓝图线程安全更新动画

这个函数主要负责收集游戏数据,并将其处理为选择和驱动动画的有用信息。

线程安全函数的一个注意事项是,我们不能像在事件图中那样直接访问游戏对象的数据,这是因为其他线程可能在同一时间运行,他们可能正在改变这些数据。

相反,我们使用属性访问系统来访问数据。在安全的情况下,属性访问系统会自动复制数据, 下面是一个例子,我们访问典当所有者的位置(从上下文菜单中搜索”属性访问”).

  • 创建自定义函数

    • Update Velocity Data
      • Details -> Advanced -> Thread Safe
      • 设置:高级 -> 线程安全 (这样才能在BlueprintThreadSafeUpdateAnimation使用这个函数)
      • 计算 World Velocity,World Velocity 2D,Local Velocity 2D,Has Velocity
    • Update Rotation Data:
      • GetOwningActor.GetActorRotation
      • 计算 World Rotation
    • Update Acceleration Data
      • 计算 World Acceleration,World Acceleration 2D,Local Acceleration 2D,Has Acceleration
  • FSM

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Locomotion_SM:
Idle2Start :
HasAcceleration
# 条件提升为公有变量
bp:Details -> Transition -> Transition Rule Sharing -> Promte To Shared -> ToStart
# 优先混合下半部分
bp:Details -> BlenderSetting -> Blend Profile -> FastFeet
Start2Cycle :
# 自然过度到下一个动画 (上一个动画完结就播放下一个动画)
bp: Details -> Transition -> Automatic Rule Based on Sequence Player in State -> T
Cycle2Stop :
Not HasAcceleration
bp:Details -> Transition -> Transition Rule Sharing -> Promte To Shared -> ToStop
Stop2Idle :
bp: Details -> Transition -> Automatic Rule Based on Sequence Player in State -> T
Start2Stop:
bp:Details -> Transition -> Transition Rule Sharing -> ToStop
Stop2Start:
bp:Details -> Transition -> Transition Rule Sharing -> ToStop

动画层接口

创建一个 ALI_AnimLayerInterface 动画层蓝图

  • 创建四个Layer

    • FullBody_Idle

    • FullBody_Start

    • FullBody_Cycle

    • FullBody_Stop

  • ABP_CharacterBase 继承ALI_AnimLayerInterface

    • 在bp: ABP_CharacterBase -> Class Setting -> Details -> Implemented Interfaces -> Add -> ALI_AnimLayerInterface

编译后把四个Layer拖入FSM的节点中

创建 ABP_ItemLayersBase 也继承于 ALI_AnimLayerInterface

这个类用于实现逻辑

FullBody_Idle:

  • Sequence Player
    • bp: Sequence Player -> Details -> Settings -> Sequence -> Bind -> 新建Anim Sequence 的变量 Idle

同理所有Layer处理

  • 在start 和 stop 中 bp: Sequence Player -> Details -> Settings -> Loop Animation -> False

创建 ABP_ItemLayersBase 子蓝图 ABP_Pistol_Layers

bp: ABP_Pistol_Layers - > Anim Preview Editor -> Default -> 设置动画

距离匹配-步幅匹配-同步组

距离匹配

前置需要插件 Animation Locomotion Library

Start

ABP_ItemLayersBase -> Sequence Evaluator -> Datail -> Settings -> Sequence (Bind Start) , Explicit Time (Dynamic), Should Loop (F) ,Teleport to Explicit Time (F)

Explicit Time 显式时间:动画Timeline中的播放到哪一帧的时间

新建函数 On Become Relevant -> SetUpStartAnim ,On Update-> Update Start Anim

  • SetUpStartAnim
    • 初始化 Set Explicit Time (0)
  • Update
    • UpdateStartAnim
      • 设置Explicit Time 使用 Advance Time By Distance Matching
      • “Advance Time By Distance Matching”:基本原理是根据角色在游戏世界中的实际移动距离来计算动画的播放时间。例如,如果角色在一帧内移动了1米,那么动画将播放1米对应的时间。这样,动画的播放速度将根据角色的实际移动速度进行调整,从而使动画与实际移动更加协调。
    • Anim
      • 在Anim中 添加修饰符 DistanceCurveModifier
      • LocamotionDistance Curve Name:指动画的动画曲线名字,由Locomotion 插件生成的可以删除Distance, 由动画数据修饰符重新引用就创建出来了
      • 压缩需要修改 为 UniformAnimCurveCompression
      • 这边新建一个解码器设置为Uniform Indexable 并把所有相关动画压缩

Cycle

循环动画,修改播放率

  • Update Cycle Anim
    • 并且勾上LoopAnimation
    • 使用Set Playrate to Match Speed

Stop

利用预测停止点处理

  • Update Stop Anim
    • if 有速度 and 没有加速度
    • Predict Ground Mevement Stop Location
    • if stop Loaction > 0.0
      • T-Distance Match to Target
      • F-Advance Time

步幅匹配

动画在不同速度下,跨的幅度不一样

在Start 和 Cycle动画添加跨步扭曲,Stop不用设置设置移动速率 作为跨步的参数

  • FullBody_Start

    • 连接 Stride Warping (跨步扭曲) — 通过以指定缩放和朝向扭曲腿步伐来调整动画的速度。

    • bp Stride Warping

      img

同步组

同步组(Sync Groups) 可用于在混合过程中自动同步相关动画的长度和播放,从而改善动画蓝图(Animation Blueprints) 中的混合行为。在混合拥有不同长度周期的步行和跑步动画时,这很有用。如果没有同步组,直接从一个周期混合到另一个周期可能会导致效果不自然,因为脚的落点可能不同步。

  • bp 序列求职器
    • Group Name -> Loacomotion
    • Method -> Sync Group
  • Anim
    • 修饰符 -> SyncMarkerAnimModifier
    • 这个左右脚落下会有标记

八方向