动画系统概述

本页面的内容:

虚幻引擎 4虚幻 4)的动画系统能对骨骼网格物体进行深度设定,以便服务于游戏角色的需要。 在这篇文档中,提供了关于虚幻 4 的动画系统如何工作的概要说明,以及关于使用这套动画系统的基础知识。

对网格物体进行骨架的绑定,结合对顶点数据的变形(Morph)的 动画 系统能够执行复杂的动画计算。 这套系统能够完成从最基础的移动行为,到根据游戏过程混合预制的动画序列来获得真实的动画效果, 比如使用动画蒙太奇(AnimMontage)来计算在窗台上移动或者墙上行走的动画表现, 或者配合受伤效果以及利用 MorphTarget 显示面部表情,又或者通过 SkeletalControl 直接控制骨骼变形。

这篇文档的目的是提供一个虚幻 4 动画系统的概述,主要是面向刚刚开始使用虚幻 4 的动画系统的人员。这并不是虚幻 4 引擎动画系统和动画资源的完整手册。 可以把这个文档看作为帮助熟悉动画系统一些方面的入门说明,解释了几个不同的部分是如何协同工作的,并展现这个动画系统的灵活性以及可以基于这个灵活性完成的强大效果。

我们先来定义虚幻 4 的动画系统中主要的术语和概念。

PersonaIcon.png

Persona (角色编辑器)是虚幻引擎中的动画编辑工具集。这是一个健壮的系统,可用来编辑骨架,骨架网格物体,动画蓝图以及多种其它动画资源。 在虚幻引擎中,大部分(即时不是全部)动画处理工作都在这个编辑器中进行。这是一款多功能的工具,包含了用于编辑骨架 插槽 、预览 动画序列 、设置动画 混合空间 以及 蒙太奇 、编辑 动画蓝图 等的面板。

SkeletonImage.png

A Skeleton is a hierarchy of bone locations and rotations used to deform a Skeletal Mesh. In UE4, Skeletons are abstracted from Skeletal Meshes in their own asset. This means that animations are applied to the Skeleton, rather than the Skeletal Mesh. By using the same Skeleton, multiple Skeletal Meshes can share animations.

AnimSequenceIcon.png

AnimationSequence(动画序列) 是一个可以在骨架网格物体上播放的独立的动画资源。它们包含了一些关键帧,这些关键帧可以及时地指出某个特定点处的一个骨骼的位置、旋转度及缩放比例。通过在序列中播放这些关键帧,让 骨架网格物体 的骨骼之间进行混合,使得骨骼可以产生平滑的动画效果。

Additive Animation

Animations can be used as absolute or additive at any time. The system performs the appropriate calculations to convert the data to offsets when necessary. This makes the system much more flexible than that of previous versions of the engine since you do not have to specify ahead of time that an animation is to be considered additive.

Blending Animations

Animations can be blended together to create more complex final poses through the use of 混合节点 and 混合空间 . For instance, a running animation can be blended with aim poses or facial animation to create an output animation of the player running and aiming or talking at the same time while being able to keep the source animations separate. This allows for the reuse of a single source animation in many circumstances.

Animation Poses

An Animation Pose is essentially a snapshot of the Skeleton, including the position and rotation of all of its bones. Think of a pose as what you see if you pause the playback of an animation. For example, if you paused a run animation mid-stride, you might see something like this:

AnimationPose_Running.png

It is as if the mesh, via the underlying Skeleton, has been posed. The data that represents the transforms of all of the bones in the Skeleton is what makes up the actual Animation Pose.

Some AnimationSequences are designed purely to be used as poses. For instance, you might have a series of short one- or two-frame animations that simply define a pose. The pose below is from this type of Animation Sequence, which is designed to be used to cause the mesh to aim its weapon where the player is looking.

AnimationPose_Aiming.png

The Animation system uses this concept of Animation Poses within the AnimGraph. The data output from an AnimationSequence, Blendspace, or simple blend node is an Animation Pose, or snapshot of the animation up to that point, to apply to the SkeletalMesh.

Component vs Local Space

动画姿势可以在 本地空间 中也可以在 组件空间 中。动画蓝图动画图表 中的 Convert Spaces(转换空间) 节点提供了在 本地空间组件空间 间转换姿势的功能。本地空间假设 骨骼的变换是相对于那根骨骼进行的。组件空间假设该骨骼的变换是相对于 SkeletalMeshComponent(骨架网格物体组件) 的。

一般,当在 动画蓝图 中应用姿势时,这些姿势位于本地空间中。但是,某些混合节点和所有的 SkeletalControls(骨架控制) 都是在组件空间中运作的。这意味着,输入姿势在传入到这些类型的节点之前需要先进行转换 。如果输入姿势来自于一个输出到本地空间的节点 ,那么在 SkeletalControl 在其上面执行任何操作之前,必须将其转换到正确的空间中。 在 SkeletalControl 执行完操作之后,所得到的姿势必须转换回到 本地空间中,以便作为其他混合或 Result 节点的输入。

Morph Targets

顶点变形目标是已经以某种方式发生变形的特定网格物体的顶点位置的快照。比如,您可以取一个角色模型,重新塑造他们面部的形状来创建面部表情,然后将已编辑的版本保存为顶点变形目标。在虚幻编辑器中,您可以混合顶点变形目标,来使得角色面部产生那个表情。顶点变形目标可以通过FBX导入到虚幻编辑器中,并且将会被封装在一个动画序列内。

这使得可以轻松地将复杂的顶点变形目标导入到虚幻编辑器中,因为您可以具有启动一个动画的多个顶点变形目标。比如,您可以在您的动画包中使用顶点变形目标来使得角色产生动画来说一段对话。该动画可以使用任何数量个顶点变形目标来捕捉脸部的完整动作。然而,当导入时,结果看上去就仅是一个单独的动画序列。您仍然可以通过曲线 来访问每个顶点变形目标的动画数据。

ParticleEffectNotify.png

动画通知(简称AnimNotifies或通知)使得动画相关的程序员可以设置在动画序列的特定点处发生的事件。通知通常用于这样的特效,比如走动时的脚步声、跑动动画或在动画中产生一个粒子特效。然而,它有很多种不同的用途,因为您可以使用自定义的通知类型来扩展该系统,从而满足任何类型游戏的需求。

Vim Blueprint

动画蓝图 从本质上讲是个专有蓝图 ,它的图表可以控制 骨架网格物体 的动画。 它可以执行动画混合,直接控制骨架的骨骼,并在每一帧对 SkeletalMesh(骨架网格物体) 输出最终姿势。

Controller(控制器) 根据玩家输入或者基于游戏环境作出的决定指示其 Pawn (或 角色 )进行移动。 每个 Pawn 有一个 骨骼网格物体组件(引用要产生动画的 骨架网格物体 ) 和 一个 动画蓝图实例 。 动画蓝图 通过它的两个图表,可以访问它所具有的 Pawn 的属性,可以计算进行动画混合、状态变换或驱动 动画蒙太奇 所使用的值,可以根据 动画序列 的混合计算 骨架网格物体 的当前姿势、还可以通过 骨架控制器 指示 骨骼_ 进行变换。

Blendspace

Blendspaces(混合空间) 是可以在 AnimGraphs(动画图表) 中进行采样的特殊资源,它可以基于两个输入值混合多个动画。基于一个输入值简单地混合两个动画可以使用动画蓝图内其中一个标准的混合节点 来实现。混合空间 提供了基于多个值(目前限定为2个值)对多个动画进行复杂混合的方法。

混合空间 的目标是减少创建一个独立的、硬编码的节点来执行基于多个特定属性或条件的 混合的需要。通过允许动画师或程序员指定 输入值、动画及如何使用输入值混合动画的方法, 使得通过这个通用的 混合空间 几乎可以执行任何类型的动画混合。

MontageIcon.png

动画蒙太奇(简称蒙太奇)是一种多功能工具,通过它可以实现多种动画效果,主要与公开代码或 蓝图可视脚本 中的动画控件相关。它也可用于创造各种动画效果,包括动画的智能循环,基于逻辑的动画切换,等等。

SkelControl

SkeletalControls(骨架控制器) ,也称为 kelControls ,可以直接控制骨架中的骨骼。这些骨架控制器可以用于在 Animation Blueprints(动画蓝图) 中控制一个单独的骨骼、创建IK链等。这种直接控制底层 骨架 的方式可以创建程序化的、动态可变的动画。一个骨骼的 变换 可以用于驱动另一个骨骼;或者当播放一般的走路动画时,可以使用踪迹来使得角色的脚部贴合地面。您可以应用任何类型的修改来调整或完全覆盖 AnimationSequences(动画序列) 对骨骼的 变换操作_ 。

System Breakdown

The following is a simple breakdown of where certain parts of the animation system are created and edited.

CreationDiagram.png

This diagram illustrates the flow and ownership of data for a typical animated character in Unreal.

AnimationDiagram.png

Animation Content Examples

A practical application of the animation system and its features are on display inside the Animation Content Examples page.

Here you will be able to follow along by looking at bite-sized examples of each feature along with additional details.

For more information on Content Examples and how to use them, refer to the Content Examples Overview page.

Animation Debug Features

Debug features can be accessed by pressing the ` key to bring up the console while in play mode.

Rendering Skeletal Mesh Bones

images/AnimationShowDebugBones.jpg

To display the Skeletal Mesh Bones, enter the ShowDebug Bones command inside the console. As seen in the image above the bones are represented by individual white lines.

The ShowDebug Bones command will display the information for the playable character during a play session. To view the debug animation for another character (other than the player character), you can use the viewactor ExampleCharacterID command, where ExampleCharacterID refers to the Character ID assigned to the character you wish to view. You can find this ID by hovering over a character in the World Outliner which will display its ID name.

At this time when using the viewactor command, the camera will be moved to and locked on the Actor you are currently viewing. If you need to manipulate the camera while debugging still, a work around for this is to create a Play in Editor session with more than one player from the dropdown menu using one window for debugging and the other for controlling a player character.

An alternative look, matching the bones displayed in Persona, can be enabled by entering the ShowDebugToggleSubCategory 3DBones command inside the console.

Animation Debug Output

images/AnimationShowDebugToggle.jpg

The Animation Debug Output information can be enabled by using the ShowDebug Animation command inside the console.

The information displayed is split up into 5 sections, each of which can be toggled on and off using the ShowDebugToggleSubCategory command followed by the category name listed below (e.g. ShowDebugToggleSubCategory SyncGroups).

Button Description
SyncGroups Displays the animation assets currently contributing to the final pose, organized by their sync group (or Ungrouped if they do not belong to a group). By default Blendspaces listed in this section show all their contributing animations/weights. To reduce screen space used by the output this can be toggled off with ShowDebugToggleSubCategory FullBlendspaceDisplay.
Montages Lists the montages currently being used by the character. The active montage is highlighted in green.
Curves Lists the curve values (in Name: Value pairs) that have been activated by the playing animation(s).
Notifies Display any notify states that are currently in effect.
Graph Displays the active pose graph. The display starts with the last node (the root node) which represents the final pose and goes on to list all the nodes that go into making that final pose. Nodes are represented in such a way as to keep their hierarchy, allowing the user to see which nodes are connected to what without having to refer to the original Blueprint asset. Active nodes are colored green and (if they have been toggled to display using ShowDebugToggleSubCategory FullGraph) inactive nodes are colored grey.