![](https://i-blog.csdnimg.cn/blog_migrate/37530b12da85a58e80d0915183b82e80.png)
unity 等待...动画
The Animation Rigging package for Unity 2019.1 enables users to set up procedural motion on animated skeletons at runtime. You can use a set of predefined animation constraints to manually build a control rig hierarchy for a character or develop your own custom constraints in C#. This makes it possible to do powerful things during gameplay such as world interactions, skeletal deformation rigging, and physics-based secondary motion.
Unity 2019.1的Animation Rigging软件包使用户可以在运行时在动画骨骼上设置程序动作。 您可以使用一组预定义的动画约束来手动为角色构建控制装置层次结构,或在C#中开发自己的自定义约束。 这样就可以在游戏过程中做一些有力的事情,例如世界互动,骨骼变形操纵和基于物理的辅助运动。
We’re happy to introduce the new Animation Rigging as a preview package for Unity 2019.1. This blog post will provide an introduction and some examples of how you can use it. Please also check out the video of our Animation Rigging GDC 2019 presentation, it’s freely accessible on the GDC Vault.
我们很高兴推出新的 Animation Rigging 作为 Unity 2019.1 的预览包 。 这篇博客文章将提供介绍和一些使用示例。 另请查看我们的 动画索具GDC 2019演示文稿 的视频,该视频 可在GDC Vault中免费访问。
入门 (Getting started)
![](https://i-blog.csdnimg.cn/blog_migrate/f12dd47fcb7a1a4f078fe5469e872b98.png)
You can now install the Animation Rigging package in your Unity projects from Package Manager. (Be sure to show Preview packages in the Advanced tab of Package Manager) The package page includes links to documentation along with some samples to help everyone get up to speed with using the package. This is our first release as a preview package for Unity 2019.1. You can also try out our next iteration for 2019.2 in the public beta. Using this upcoming version, you can use the Animation Window to author your own constraints animations with live feedback.
现在,您可以从Package Manager在Unity项目中安装Animation Rigging软件包。 (请确保在“程序包管理器”的“高级”选项卡中显示“预览”程序包)。“程序包”页面包含 文档 链接 以及一些示例,以帮助所有人快速使用该程序包。 这是我们作为Unity 2019.1预览包的第一个版本。 您也可以 在公开测试版中试用 我们对 2019.2 的下一个迭代 。 使用此即将发布的版本,您可以使用“动画窗口”来创作自己的带有实时反馈的约束动画。
A brief note about what we mean by preview: please be aware that things in this package will change as we update to new versions. The exciting part is that you have the opportunity to influence our development and make sure it works for what you need. So please stay in touch with us and let us know how it goes. We are very eager to hear your input.
关于预览的含义的简要说明:请注意,随着我们更新到新版本,此软件包中的内容将发生变化。 令人兴奋的是,您有机会影响我们的发展,并确保它能满足您的需求。 因此,请 与我们保持联系, 并告诉我们如何进行。 我们非常希望听到您的意见。
动画索具概述 (Animation Rigging overview)
![](https://i-blog.csdnimg.cn/blog_migrate/ecc837ff9deedea003ff02c67686f255.png)
The Animation Rigging package provides a library of rig constraints that you can use to create procedural motion at runtime. This is commonly known as runtime rigging. The constraints are set up in groups called Rigs, which are assembled in the Rig Builder component that is assigned to the asset’s Animator Root.
动画索具包提供了绑定约束库,可用于在运行时创建过程运动。 这通常称为运行时绑定。 约束在称为“钻机”的组中进行设置,这些组在分配给资产的“ Animator Root”的“ Rig Builder”组件中进行组装。
![](https://i-blog.csdnimg.cn/blog_migrate/04ebd77518d826eceec886cde8a6ba5d.png)
This enables users to do powerful things with animated skeletons during gameplay, such as world interactions. For example, when a character’s hands interact with a prop, or to aim at a target in the world. It’s also possible to get higher quality rigging using procedurally controlled bones for skeletal deformation rigging, such as twist correction for shoulders and wrists on skinned mesh characters. We also have physics-based constraints that can be used for dynamic secondary motion on character rigs.
这使用户可以在游戏过程中使用动画骨架来完成强大的功能,例如世界互动。 例如,当角色的手与道具互动或瞄准世界上的目标时。 还可以使用程序控制的骨骼进行骨骼变形绑定(例如对蒙皮网格物体的肩膀和手腕进行扭曲校正)来获得更高质量的绑定。 我们还具有基于物理的约束,可用于角色装备上的动态辅助运动。
骨骼渲染器 (Bone Renderer)
For working with rigs in the Unity Editor, it helps to see and interact with the skeleton in Scene view. We now have the Bone Renderer component, which allows you to add a list of transforms and display them in a variety of visual styles.
为了在Unity编辑器中使用装备,它有助于在“场景”视图中查看骨架并与之交互。 现在,我们有了Bone Renderer组件,该组件使您可以添加变换列表并以各种视觉样式显示它们。
![](https://i-blog.csdnimg.cn/blog_migrate/94574399082631530eca678b7416936b.png)
It often helps to organize parts of the skeleton using multiple Bone Renderer components. Here is an example where the same character has multiple Bone Renderer components so that the body, fingers and twist bones can each have their own display styles. This helps to facilitate different artist workflows such as rig setup, keyframing or gameplay debugging.
它通常有助于使用多个Bone Renderer组件来组织骨骼的各个部分。 这是一个示例,其中同一角色具有多个Bone Renderer组件,因此,身体,手指和扭骨可以各自具有自己的显示样式。 这有助于简化不同的艺术家工作流程,例如装备设置,关键帧或游戏调试。
钻机制造商和钻机 (Rig Builder and Rigs)
Here are instructions for setting up Rigs on a character:
以下是在角色上设置装备的说明:
First, we need to add the Rig Builder component to the Animator root. This is the same GameObject where the Animator component is assigned. Typically, this is the topmost transform in the rig hierarchy.
首先,我们需要将Rig Builder组件添加到Animator根目录。 这是分配了Animator组件的同一GameObject。 通常,这是装备层次结构中最顶层的变换。
Next, we can create a new child GameObject and that is where we will add the Rig component.
接下来,我们可以创建一个新的子GameObject,并在其中添加Rig组件。
Finally, the Rig gets assigned to the Rig Layers list in Rig Builder.
最后,将“装备”分配给“装备生成器”中的“装备层”列表。
This is the minimal valid rig setup. In the next steps, we add constraints.
这是最小的有效装备设置。 在接下来的步骤中,我们添加约束。
![](https://i-blog.csdnimg.cn/blog_migrate/70a06fbe404957ca3c5091c1dd871856.png)
The really great thing about Rig Builder is that the Rig Layers list allows for multiple rigs as seen in the image above. This is very useful for creating specialized behaviors that can be turned on and off during gameplay. And to make it even more useful, each Rig has its own weight value so it can be blended with the other Rigs.
Rig Builder的真正妙处在于,“钻机层”列表允许多个钻机,如上图所示。 这对于创建可以在游戏过程中打开和关闭的特殊行为非常有用。 为了使它更加有用,每个钻机都有自己的重量值,因此可以与其他钻机混合。
钻机约束 (Rig Constraints)
Rig Constraints are the building blocks that are used to assemble rigs and produce procedural motion at runtime. They’re designed to be modular and general-purpose so that they can be combined in many different ways to solve the needs of your animation game designs in runtime.
钻机约束是用于组装钻机并在运行时产生程序运动的构造块。 它们被设计为模块化和通用的,因此可以通过多种不同方式组合起来,以解决运行时动画游戏设计的需求。
Here is the list of Rig Constraints that are being released with the package.
以下是与软件包一起发布的绑定约束列表。
![](https://i-blog.csdnimg.cn/blog_migrate/85b59439d6ee00029bbc6e3813b5927c.png)
Here are steps for how to set up a Rig Constraint. In this example, we’re using the TwoBoneIK Constraint.
以下是有关如何设置装备约束的步骤。 在此示例中,我们使用TwoBoneIK约束。
First, add a child GameObject below the Rig.
首先,在装备下方添加一个子GameObject。
Then we add a TwoBoneIK Constraint.
然后,我们添加一个TwoBoneIK约束。
Next, we assign the bones and effectors to the TwoBoneIK Constraint.
接下来,我们将骨骼和效应器分配给TwoBoneIK约束。
Lastly, when Play is pressed we can see the Constraint evaluates at runtime.
最后,当按下Play键时,我们可以看到Constraint在运行时评估。
钻机约束样本 (Rig Constraints samples)
The best way to get started and learn how the Rig Constraints work is by checking out the samples included with the package. Inside of Package Manager, there is a button to import the samples into your project. There is a scene for each constraint that demonstrates how it works.
入门和了解绑定约束的工作方式的最佳方法是检出包装中随附的示例。 在Package Manager中,有一个按钮可以将样本导入到您的项目中。 每个约束都有一个场景来演示其工作原理。
![](https://i-blog.csdnimg.cn/blog_migrate/6d1da658e70b93655a774e78103b54ea.png)
游戏实例 (Gameplay examples)
Runtime rigging happens during gameplay. So in order to try out how this works, we made a quick gameplay prototype using some existing Unity sample content.
运行时操纵发生在游戏过程中。 因此,为了尝试如何工作,我们使用一些现有的Unity示例内容制作了一个快速的游戏原型。
![](https://i-blog.csdnimg.cn/blog_migrate/103a06b807b974231e28826cd87ef38a.png)
We implemented these basic player controls and used the Animation Rigging package to get some cool gameplay mechanics very easily. Here is a quick video of what it looks like:
我们实现了这些基本的播放器控件,并使用了动画索具包来轻松获得一些很棒的游戏机制。 这是一个简短的视频:
Let’s take a look at each of these features so you can see how we made the runtime rigs.
让我们看一下这些功能中的每一个,以便您可以了解我们如何制作运行时装备。
骨骼变形钻机 (Skeletal Deformation Rig)
The ninja’s skeleton already had twist bones and skin weights set up to begin with. In Unity, we added TwistCorrection constraints to fix up the deformation on his arms and legs. The video shows what it looks like when these constraints are turned off. With the twist correction applied, the movement feels much more natural, like real anatomy and clothing:
忍者的骨骼已经开始具有扭曲骨骼和皮肤重量。 在Unity中,我们添加了TwistCorrection约束来修正他的手臂和腿部的变形。 视频显示了关闭这些约束后的外观。 应用扭曲校正后,运动感觉自然得多,就像真正的解剖结构和衣服一样:
![](https://i-blog.csdnimg.cn/blog_migrate/6a5e5ae107731a341166d622686d5706.png)
垂直瞄准装备:手里剑 (Vertical Aim Rig: Shuriken)
For the shuriken player ability, the ninja needs to be able to aim his throwing knives at any angle, 360 degrees.
为了使手榴弹的球员能力强,忍者需要能够将投掷刀对准任何角度(360度)。
To set this up we first added some new virtual bones to his skeleton.
为了进行设置,我们首先在他的骨骼中添加了一些新的虚拟骨骼。
Virtual bones in Unity are when you add new Transforms into the skeleton hierarchy and save them with the prefab. These can be animated like any other bone. They can be considered virtual because they may only have keyframes in the animation clips that need them, which saves memory elsewhere where they are not needed.
Unity中的虚拟骨骼是在将新的Transforms添加到骨架层次结构中并将其与预制件一起保存时。 这些可以像其他骨骼一样设置动画。 它们可以被认为是虚拟的,因为它们在动画片段中可能只包含需要它们的关键帧,从而在不需要它们的其他地方节省了内存。
To set this up we first added some new virtual bones to his skeleton.
为了进行设置,我们首先在他的骨骼中添加了一些新的虚拟骨骼。
Next, we added a TwoBoneIK Constraint to the left arm and set the virtual bones as the IK targets.
接下来,我们在左臂上添加了TwoBoneIK约束,并将虚拟骨骼设置为IK目标。
The IK targets were then animated in a new animation clip where he throws the shuriken. This clip is set up in the ninja’s Animator State Machine as a replacement layer. Both this layer and the vertical aim rig are activated on button press.
然后,在新的动画剪辑中对IK目标进行了动画处理,他在其中投掷了手里剑。 此剪辑在忍者的Animator状态机中设置为替换层。 按下按钮即可激活该层和垂直瞄准装备。
Finally, we made a 1D Blend Tree to drive the Aim Vertical virtual bone, which is the parent of the IK targets. This gets driven by player input, the vertical axis of the left analog thumbstick on a gamepad controller.
最后,我们制作了一维混合树以驱动“垂直目标”虚拟骨骼,该骨骼是IK目标的父级。 这是由玩家输入驱动的,即游戏手柄控制器上左模拟指尖的垂直轴。
![](https://i-blog.csdnimg.cn/blog_migrate/3381ce72eaedd79996a87fdc1664e1e2.png)
As a result, this animation layer overlays on top of any animation the ninja may be playing. This always works whether he is running, jumping, crouching or even attacking with his sword he can immediately throw a shuriken as a ninja should.
结果,此动画层将叠加在忍者可能正在播放的任何动画之上。 无论他是奔跑,跳跃,蹲下,甚至是用剑进攻,这总是有效的,他可以立即按照忍者的要求投掷手榴弹。
垂直瞄准装备:武士刀 (Vertical Aim Rig: Katana)
The ninja’s katana also needs to be able to aim vertically in order to hit targets that might be on the ground or overhead. We made this building on top of the shuriken rig. It uses the same 1D Blend Tree to control aiming.
忍者的武士刀还需要能够垂直瞄准,以击中可能在地面或头顶的目标。 我们在shuriken钻机顶部建造了这座建筑物。 它使用相同的1D混合树来控制瞄准。
Sword animations bring a new factor: the horizontal rotation. It’s very important for this horizontal aim to be perfectly straight so that the sword trail effect looks smooth. It can be difficult to make this look straight using only skeletal animations because even if the poses are perfect, there are often imperfections in sub-frames. This is because of the way the interpolations solve on the arm’s FK bone chain. The best way to fix this is by using a Multi-Aim Constraint.
剑动画带来了新的因素:水平旋转。 使水平瞄准镜完美笔直非常重要,这样剑道效果看起来很平滑。 仅使用骨骼动画很难使它看起来直,因为即使姿势完美,子帧中也经常有瑕疵。 这是因为插值在手臂的FK骨骼链上求解的方式。 解决此问题的最佳方法是使用“多目标约束”。
![](https://i-blog.csdnimg.cn/blog_migrate/cb6e459b07c3962baabb96eaa3cccf85.png)
We set up a new virtual bone and moved it out in front of the katana. Then we assigned this as the target of a Multi-Aim Constraint. The source object of this is the right-hand grip bone, which is the parent of the katana model.
我们设置了一个新的虚拟骨骼并将其移到武士刀前面。 然后,我们将其指定为“多目标约束”的目标。 该对象的源对象是右手握骨,是katana模型的父代。
Next, we added another virtual bone as the parent of the aim target and used a Position Constraint to keep it centered on the ninja’s chest.
接下来,我们添加了另一个虚拟骨骼作为目标目标的父对象,并使用“位置约束”将其保持在忍者胸部的中心。
Finally, we opened the sword swipe animation clip and added keyframes for rotating the parent of the aim target in sync with the motion of the arm.
最后,我们打开了剑滑动动画剪辑,并添加了关键帧以与手臂的运动同步旋转目标目标的父对象。
The result is that the Multi-Aim Constraint corrects any imperfections in the horizontal rotation arc of the sword. Even when the animations are slowed down and have particle effects added as shown in the above video, the sword strike is always straight and true.
结果是,多重目标约束可以纠正剑的水平旋转弧中的任何缺陷。 即使如上视频所示,放慢了动画的速度并添加了粒子效果,剑的打击也总是笔直而真实的。
蝴蝶熟悉的钻机 (Butterfly Familiar Rig)
Here is another example of how Rig Constraints helped us to make a follower character. We used the DampedTransform Constraint to make the butterfly follow a target Transform in the ninja’s prefab. It also uses a Multi-Aim Constraint to shine a spotlight that always aims at a target in front of the ninja wherever he goes.
这是“绑定约束”如何帮助我们树立追随者角色的另一个示例。 我们使用DampedTransform约束使蝴蝶跟随忍者预制件中的目标Transform。 它还使用“多目标约束”来照亮聚光灯,无论他走到哪里,该聚光灯始终对准忍者前方的目标。
![](https://i-blog.csdnimg.cn/blog_migrate/4ef558152236fce5e0c46f7b6a8acbee.png)
You might recognize the butterfly model from our earlier blog post on the HD Lit Master Node for Shadergraph. What we didn’t know at the time is that this is the ninja’s messenger butterfly – he gives him power-ups and special attacks. Most importantly it keeps him company while he runs through the Megacity. Anyway, you can invent whatever cool gameplay mechanics you like and the Animation Rigging package makes it easy to implement.
您可能会从我们之前在 Shadergraph 的 HD Lit Master Node 上的博客文章中认识到蝴蝶模型 。 当时我们还不知道这是忍者的信使蝴蝶-他给了他力量增强和特殊攻击的机会。 最重要的是,当他穿越大城市时,这可以使他保持陪伴。 无论如何,您都可以发明自己喜欢的任何酷炫的游戏机制,而“ Animation Rigging”软件包可以轻松实现。
机械起重机的例子 (Mechanical Crane example)
The animation rigging constraints can not only be used for characters, but also for anything else. In this example, we used these constraints to build a futuristic mechanical crane rig. The goal was to create a rig that is entirely driven by inputs and constraints at runtime. There are no animation clips in this example, as all motion is derived from two gamepad joystick inputs and one button to trigger the clamp & release of the container.
动画绑定约束不仅可以用于角色,还可以用于其他任何东西。 在此示例中,我们使用这些约束条件构建了一个未来派机械起重机。 目标是创建一个在运行时完全由输入和约束驱动的装备。 在此示例中没有动画剪辑,因为所有运动均来自两个游戏手柄操纵杆输入和一个按钮来触发容器的夹紧和释放。
Note: HDRP textures are not included in the sample project.
注意:HDRP纹理不包括在示例项目中。
You can download mechanical crane sample project for Unity 2019.1 on GitHub.
您可以 在GitHub上 下载 Unity 2019.1的机械起重机示例项目。
If you’re using Unity 2019.2 beta, download this updated version of the project.
如果您正在使用 Unity 2019.2 beta ,请 下载 此项目的更新版本。
The controls for the crane are:
起重机的控件为:
![](https://i-blog.csdnimg.cn/blog_migrate/65843fd9b667b654d788536341ba3f8d.png)
![](https://i-blog.csdnimg.cn/blog_migrate/c902a5b2a9a7c37b344b6e0b27140502.png)
控制装备 (ControlRig)
In this example, we took the approach of creating two rigs. First, a ControlRig that basically mimics the model hierarchy in order to input and solve the desired result in an animation stream (aka the ControlRig)
在此示例中,我们采用了创建两个装备的方法。 首先,一个ControlRig基本上模仿模型层次结构,以便在动画流中输入并求解所需的结果(也称为ControlRig)
The red part of the rig represents the inputs or desired targets, whereas the green represents the actual/current result.
装备的红色部分表示输入或所需的目标,而绿色部分表示实际/当前结果。
变形钻机 (DeformRig)
Second, a DeformRig takes the final result of the ControlRig and applies it the model hierarchy + secondary piston movement:
其次,DeformRig获取ControlRig的最终结果,并将其应用于模型层次结构+辅助活塞运动:
The final result on the rig is then applied to the models or joints in the scene.
然后,将钻机上的最终结果应用于场景中的模型或关节。
钻机结构 (Rig Structure)
The inputs for the crane’s arm are driving rig effectors using a simple script and the Rig Transform component to obtain the proper scene/input evaluation. These inputs are then damped onto a second effector. The remaining effectors, including the container rotation and clamps, are children of this damped result. In this example, the ControlRig uses 15 constraints: Damp for the inputs, 2BoneIK for the arm, multiple constraints for the clamps and container release. The DeformRig uses a flat list of constraints: Aim & Multi-Position for the pistons & Multi-Parent Constraints for the rig-to-model remapping.
起重机臂的输入是使用简单的脚本和“钻机变换”组件的钻机效应器,以获得正确的场景/输入评估。 然后将这些输入阻尼到第二个效应器上。 其余的效应器,包括容器旋转和夹具,都是这种衰减结果的子代。 在此示例中,ControlRig使用15个约束:Damp用于输入,2BoneIK用于臂,多个约束用于夹具和容器释放。 DeformRig使用简单的约束列表:“目标”和“多位置”用于活塞,“多父对象”约束用于“钻机到模型”重新映射。
There are, of course, many ways that this example could have been rigged to obtain the same or similar result. Keep in mind that the rig hierarchy (order of GameObjects in the scene) controls the order in which the constraints are evaluated. This is extremely important in cases like this, where certain constraints need to be evaluated in a specific order.
当然,可以使用多种方法来操纵此示例以获得相同或相似的结果。 请记住,装备层次结构(场景中GameObjects的顺序)控制评估约束的顺序。 在这种情况下,这是非常重要的,在这种情况下,需要按特定顺序评估某些约束。
Hope you’ve found this blog post useful in understanding how to manage inputs, Rig Transforms and different types of rigs & constraints. Have fun! We’re looking forward to hearing your feedback on the forums.
希望您发现此博客文章对理解如何管理输入,装备转换和各种类型的装备与约束有用。 玩得开心! 我们期待着您 在论坛上收到 您的 反馈 。
—
-
Want to continue learning about rigging? Check out our courses and tutorials on the Unity Learn Premium platform.
是否想继续学习索具? 在Unity Learn Premium平台上 查看我们的 课程和教程 。
unity 等待...动画