高级动画索具:角色与道具互动

Earlier this year we introduced the Animation Rigging package. Our initial goal was to provide a suite of constraints that can be used to create different rigs to alter or modify your animation at runtime. 

今年早些时候,我们推出了“ 动画索具”软件包 。 我们的最初目标是提供一组约束,可用于创建不同的装备以在运行时更改或修改动画。

We’ve been exploring many of the possibilities that this package offers, pushing the boundaries between runtime and authoring. This article sheds light on some of our recent Animation Rigging experiments. PLEASE be aware that the state machine in the following example is experimental, not necessarily representative of a viable production example. We are simply exploring how a technical animator might author constraint interactions with a state machine without needing to write any code.

我们一直在探索该程序包提供的许多可能性,从而突破了运行时和创作之间的界限。 本文阐明了我们最近进行的一些动画索具实验。 请注意,以下示例中的状态机是实验性的,不一定代表可行的生产示例。 我们只是在探索技术动画师如何编写与状态机的约束交互而无需编写任何代码。

We hope this article will inspire you to explore and discover new ways to address the animation challenges you face every day. To build a viable and complete animation solution, we believe it’s in our best interest to find out what you discovered and what you need.

我们希望本文能够激发您探索和发现新方法,以解决您每天面临的动画挑战。 为了构建可行且完整的动画解决方案,我们相信找出您发现的内容和需要的内容是我们的最大利益。

基础 (The basics)

This blog will focus on three types of component: Rig Builder, Rig, and various kinds of Constraints. If you’re not already familiar with these, we suggest you consult our previous blog post on Animation Rigging.

该博客将重点介绍三种类型的组件:Rig Builder,Rig和各种Constraints。 如果您还不熟悉这些内容,建议您参考 以前 有关“动画索具”的 博客文章

In order to follow along more easily, you might want to download the project we’re referencing here.

为了更轻松地进行后续操作,您可能需要下载我们在 这里 引用的项目 。

一点点状态 (A little bit of state)

The first thing we decided we needed was to find a way to make it so that the rig constraints can be animated within the context of an existing Animator (state machine logic with read-only clips), without any direct user code intervention. We’ve found a solution in the state machine (Animator) Layers.

我们决定需要做的第一件事是找到一种制作方法,使绑定约束可以在现有Animator(带有只读剪辑的状态机逻辑)的上下文中进行动画处理,而无需任何直接的用户代码干预。 我们已经在状态机(Animator)层中找到了解决方案。

将动画绑定与现有状态机集成 (Integrating animation rigging with an existing state machine)

To properly synchronize the activation of the rigs and constraints with the read-only clips in the existing state machine, we leveraged the Animator state machine Layers. 

为了使装备和约束的激活与现有状态机中的只读剪辑正确同步,我们利用了Animator状态机图层。

Using the animation window we’ve created several animation clips (stored in the *Rig Layers) that animate the rigs and constraint properties. Again, we are simply animating Weight and Source Weight properties of different rigs and constraints.

使用动画窗口,我们创建了几个动画片段(存储在* Rig Layers中),以动画化装备和约束属性。 同样,我们只是对不同装备和约束的“权重”和“源权重”属性设置动画。

Note that we also used the “Player” script to activate or deactivate some Weight Layer properties for an alternative hang grip. This is a slider on the Player script that changes the handgrip pose.

请注意,我们还使用“ 播放器” 脚本来激活或取消激活某些“重量层”属性,以替代悬挂夹点。 这是Player脚本上的滑块,用于更改手柄姿势。

忍者的枪 (The Ninja’s guns)

建造忍者装备 (Building the Ninja Rig)

The Rig Builder component provides you with the Rig Layers you need to re-order and ensure the desired evaluation and solving results between rigs/rig parts. This provides flexibility for rig combinations and the ordering of solves. For instance, let’s see what happens if we deliberately misorder the Shoulder Offset Rig in our ninja example.

“钻机生成器”组件为您提供需要重新订购的“钻机层”,并确保在钻机/钻机零件之间进行所需的评估和求解结果。 这为钻机组合和求解顺序提供了灵活性。 例如,让我们看看如果在我们的忍者示例中故意对肩偏距钻机进行错误排序会发生什么。

By moving the Shoulder Correction Rig to the bottom of the Rig Builder evaluation stack, we broke the expected solving.

通过将“肩膀校正装备”移动到“装备制造商”评估堆栈的底部,我们打破了预期的解决方案。

With the Shoulder Correction Rig at the top of the Rig Builder evaluation stack we obtain the proper solving behavior.

使用“ Rig Builder”评估堆栈顶部的“ Shoulder Correction Rig”,我们可以获得适当的求解行为。

In the top image, Shoulder Offset is placed at the bottom of the stack, resulting in a misalignment of the hands. With correct ordering, the shoulder is solved before the rest of the arm, so the hand can correctly grip the pistol. We can then adjust the Pistol handgrip using the correction provided by the RightArm IK to solve for the UpperBody Rig.

在顶部图像中,“肩膀偏移”放置在堆栈的底部,从而导致手未对准。 正确订购后,肩膀将在手臂其余部位之前解压,因此手可以正确握住手枪。 然后,我们可以使用RightArm IK提供的校正来调整手枪手柄,以解决UpperBody Rig。

Note: The following descriptions of the rig and constraints setup do not necessarily match the order in which it is represented in the image above. 

注意:以下对装备和约束设置的描述不一定与上图中的显示顺序匹配。

肩部矫正器 (Shoulder Correction Rig)

The Shoulder Correction rig is used in combination with the Right Arm Two Bone IK constraint to correct the posing of the Right Shoulder bone to match the pose delta between the Assault Rifle Idle animation and the Pistol idle Pose. 

肩部校正装备与“右臂两骨” IK约束结合使用,以校正右肩骨的姿势,以使其与“突击步枪空闲”动画和“手枪空闲姿势”之间的姿势变化相匹配。

We used the Override Transform in Pivot mode on the RightShoulder (Transform) to enforce additive rotational values on Y and Z transforms. Notice that we’re only affecting Rotation by setting the Position Weight to 0.

我们在 RightShoulder ( Transform ) 上的“ Pivot”模式中使用了“ Override Transform”, 以在Y和Z变换上强制加法旋转值。 请注意,我们仅通过将“位置权重”设置为0来影响“旋转”。

突击步枪钻机 (Assault Rifle Rig)

Check out the Hips Constraint GameObject and its children. Using the Hips Ctrl in pivot mode as a source in an Override Transform to affect the Hips bones allows us to offset the entire ninja hierarchy. Then we use a combination of constraints (Multi-Aim & Override Transform) to create an upper body aim rig that affects the spine section as well as the hips. Setting different aim weight constraint values (see, in each case, the Multi Aim Constraint > Source Objects for spine 0.35, chest 0.5, upper chest 0.75, and head 1.0) affects the distribution of rotation across all spine effectors. All of these source the Target GameObject to different degrees to create the effect.

查看臀部约束GameObject及其子代。 在枢轴模式下使用“臀部Ctrl”作为“替代变换”中的源来影响“臀部”骨骼,使我们可以偏移整个忍者层次。 然后,我们结合使用约束(多重目标和替代变换)来创建一个影响脊椎和臀部的上半身瞄准装备。 设置不同的目标体重约束值(在每种情况下,请参见“多目标约束”>“脊柱0.35,胸部0.5,上胸部0.75和头部1.0的源对象”)会影响所有脊柱效应器上的旋转分布。 所有这些都以不同程度提供了目标GameObject的效果。

武器装备 (Weapon Rig)

The Weapon Rig GameObject uses the Override Transform to allow us to hijack the Weapon Bone animation stream and redirect it using a source object (Weapon Ctrl).

Weapon Rig GameObject使用Override Transform允许我们劫持Weapon Bone动画流并使用源对象( Weapon Ctrl ) 对其进行重定向 。

We then use the same source object as a reference object in a Multi-referential constraint to gain a multi-pivot manipulation. Try playing with the values under Multi Referential Constraint > Driving to see this in action.

然后,在“多参照”约束中使用相同的源对象作为参照对象,以获得多轴操作。 尝试使用“多参照约束”>“驾驶”下的值,以查看实际效果。

上肢IK钻机 (UpperBody IK Rig)

The Two Bone IK provides the IK solving on both skeleton arms. Multi-Parent Constraints are used to attach the RHIK & LHIK Effectors to the Weapon_Bone child IK Target Game Objects  (AR_LHIK_Target & AR_RHIK_Target).

Two Bone IK提供两个骨骼臂的IK解算。 多父约束用于将 RHIK 和 LHIK效应器 附加 到 Weapon_Bone 子IK目标游戏对象( AR_LHIK_Target 和 AR_RHIK_Target )。

手枪钻机 (Pistol Rig)

To convert the original Idle Animation to a Pistol Stance we use a set of animation rigging constraints. We offset data coming from the Pistol Ctrl effector to the Weapon Bone with the help of the Override Transform using the Pivot mode option. Then, we leverage the Maintain Offset in Position & Rotation of the Multi-Parent constraint to cancel out the global coordinate discrepancy between the source (Weapon Bone) and the target (Pistol Offset) game object.

要将原始的“空闲动画”转换为“手枪姿势”,我们使用了一组动画绑定约束。 我们 使用 偏移 透视 模式选项 转换 数据从 手枪按Ctrl 效应的 武器骨 与 覆盖 的帮助下 到来 。 然后,我们利用维护 偏移 位置和 多家长 约束 的 旋转抵消全球协调源( 武器骨 )和目标 之间 的 差异 ( 手枪偏移 )游戏对象。

武器源钻机 (Weapons Source Rig)

To attach the Assault Rifle (AR) and Pistol skeletons to different anchor point, we take advantage of the multi-source functionality of the multi-parent constraint.

要将突击步枪(AR)和手枪骨架连接到不同的锚点,我们利用了多父约束的多源功能。

The Assault Rifle Attach Rig makes good use of the multi-source functionality of the Multi-Parent Constraint. When AR_Holster source is set to 1 (and Weapon_Bone source to 0) the AR_Grip_Bone attaches itself to the AR_Holster.

突击步枪装钻机 充分利用了多家长约束的多源功能。 当AR_Holster源设置为 1 (并且Weapon_Bone 源设置为0)时, AR_Grip_Bone会将 其自身附加到 AR_Holster 。

If we want the Assault Rifle (AR_Grip_Bone) to follow the Weapon_Bone we simply set the Weapon_Bone source to 1 (and AR_Holster source to 0).

如果我们希望突击步枪(AR_Grip_Bone)跟随 Weapon_Bone, 我们只需将Weapon_Bone 源 设置 为1(并将AR_Holster 源设置为0)。

Note that we can keyframe most of the properties of any constraint, and in this case each multi-parent source weight, to obtain the desired result.

注意,我们可以为任何约束的大多数属性设置关键帧,在这种情况下,为每个多父源权重设置关键帧,以获得所需的结果。

This is key. As these new animation clips will then be used in a state of a “synced” Animator controller Layer to enforce certain rig states in specific states of the existing locomotion (or other) state machine.

这是关键。 由于这些新的动画剪辑随后将在“已同步”的Animator控制器层的状态下使用,以在现有运动(或其他)状态机的特定状态下强制执行某些装备状态。

The following example demonstrates the use of a multi-parent constraint operating with three different sources (Pistol_Holster, Pistol Offset, RightHand_PistolGrip) at runtime.

下面的示例演示在运行时如何使用对三个不同源( Pistol_Holster , Pistol Offset , RightHand_PistolGrip )进行 操作的多父约束 。

The result is made possible by synchronizing two animation clips on multiple State Machine Layers:  Pistol_Equip (read only .fbx playing on the Base Layer) and Rig_Pistol_Equip (native Unity animation clip playing in the Rig Pistol Layer).

通过同步多个状态机层上的两个动画剪辑,可以使结果成为可能: Pistol_Equip (在 基层 上播放只读.fbx )和 Rig_Pistol_Equip (在 Rig Pistol层上 播放本地Unity动画剪辑 )。

腿IK钻机 (Legs IK Rig)

The .fbx Ninja contains LeftFootIK and RightFootIK objects (both children of the LowerBody GO) that have been animated in a DCC to match the Skeleton feet animation.

.FBX 忍者包含 LeftFootIK 和 RightFootIK 对象(LowerBody GO 的两个孩子 )已经在DCC被动画相匹配的骨骼动画脚。

Multi-parent constraints are used to attach the Feet IK effectors from the Leg IK Rig to the LeftFootIK and RightFootIK game objects. This creates the ability to lock both feet at the Root level allowing us to manipulate the hips without having the lower body parts go underground.

多父约束用于将“腿部IK装备”中的“脚部IK”效果器附加到LeftFootIK和RightFootIK游戏对象。 这样就可以将双脚锁定在“根”位置,从而使我们能够在不使下半身进入地下的情况下操纵臀部。

Finally, the Two Bone IK constraint provides the IK solve we need to generate the proper animation correction on the lower body (i.e. feet & hint placement ).

最后,“两骨” IK 约束提供了我们需要在下半身(即,脚和提示位置)上生成正确的动画校正的IK解决方案。

脚设置 (Foot setup)

A very successful discovery was using the Multi-Referential constraint for a foot rig. We’ve been able to leverage the manipulation of the IK effector by creating a multi-pivot foot control rig… alluding to a future animation authoring solution.

一个非常成功的发现是对脚踏钻机使用了多参照约束。 通过创建多轴脚控制装备,我们已经能够利用IK效果器的操纵……暗示了未来的动画创作解决方案。

LeftHandGrip钻机 (LeftHandGrip Rig)

We’ve duplicated the Left-Hand Game Objects hierarchy to create a different hand grip pose. Using the Rig component weight sliders, we can enable/disable the multiple Override Transform constraints (one for each of the finger Game Objects) in local mode to override the local rotation of each finger.

我们已经复制了“左手游戏对象”层次结构以创建不同的手握姿势。 使用装备部件权重滑块,我们可以在本地模式下启用/禁用多个“覆盖变换”约束(每个手指游戏对象一个),以覆盖每个手指的局部旋转。

To align the LHIK Effector to the AR_LHIK_Target_B Game Object, we set the weight of the AR_LHIK_Target to 0 and at the same time the weight of the AR_LHIK_Target_B to 1.

为了将 LHIK效应器 与 AR_LHIK_Target_B 游戏对象 对齐 ,我们将 AR_LHIK_Target 的权重设置 为0,同时将 AR_LHIK_Target_B 的权重 设置 为1。

We then use a MonoBehaviour script to synchronize the LeftHandGrip Rig weight properties and the LeftArm IK / Multi-Parent Constraint sources weight properties (AR_LHIK_Target & AR_LHIK_Target_B) to modify the Left-Hand grip pose and position on the weapon.

然后,我们使用MonoBehaviour脚本来同步 LeftHandGrip 装备 重量属性和 LeftArm IK / 多父约束 源重量属性( AR_LHIK_Target 和 AR_LHIK_Target_B ),以修改武器上的左手握持姿势和位置。

扭曲校正装置 (Twist Correction Rig)

The Twist Correction Rig acts as a procedural deformation rig. It affects the upper and lower part of each arm, as well as both upper portions of each leg. It extracts the roll rotation of the wrist bone and distributes it along the local X-axis of each twist bone according to a specific weight value.  

扭曲校正装备充当程序变形装备。 它影响到每个手臂的上部和下部,以及每条腿的两个上部。 它提取腕骨的滚动旋转,并根据特定的重量值将其沿每个扭曲骨骼的局部X轴分布。

In this example, the Twist correction is at the bottom of the Rig Builder Rig Layers. The Twist Correction can then benefit from previous alterations induced by the preceding rigging constraints.

在此示例中,“扭曲”校正位于“钻机生成器”钻机层的底部。 然后,扭曲校正可以受益于先前的装配约束所引起的先前的更改。

在此项目中发现的其他注释和学习 (Miscellaneous notes & learnings identified during this project )

Since we are using the Animator state machine to drive the constraint properties (float weights), they will inherit the transition and blending effects that come with it (ex: value may not be absolute before the blend ends… you might expect to see a value like 0.998). Make sure to leave time for your blend transitions to end before the constraint weight animation starts to avoid this issue.

由于我们使用的是Animator状态机来驱动约束属性(浮动权重),因此它们将继承其附带的过渡和混合效果(例如:在混合结束之前,值可能不是绝对的……您可能希望看到一个值例如0.998)。 确保在约束权重动画开始之前留出时间让混合过渡结束,以避免出现此问题。

Another side effect of this approach is that you may need to key properties that were affected by a previous state to ensure that they do not go back to their default value/state. This is especially important when a state does not have a clip on the synced layer. 

这种方法的另一个副作用是,您可能需要键入受先前状态影响的属性,以确保它们不返回其默认值/状态。 当状态在同步层上没有剪辑时,这尤其重要。

After addressing these issues, we ended up with something very functional and promising.

解决了这些问题之后,我们最终获得了非常有用且很有希望的东西。

结论… (In conclusion…)

We are now delighted to share the result of this experimentation with you, with hopes of getting your feedback and input on how you are using or hope to use this Animation Rigging package. 

现在,我们很高兴与您分享本次实验的结果,希望获得您对如何使用或希望使用此动画索具包的反馈和意见。

You can download the Animation Rigging Advanced Character Interaction project on GitHub

您可以在GitHub上下载“动画装备高级角色交互”项目。

Have fun, and we’re looking forward to hearing from you on the animation rigging package forum!

祝您玩得开心,我们期待在 动画装配包 论坛 上收到您的 来信

Want to continue learning about rigging? Check out our courses and tutorials on the Unity Learn Premium platform.

是否想继续学习索具? 在Unity Learn Premium平台上 查看我们的 课程和教程

Special thanks to Yang-Hai Eakes, Simon Bouvier-Zappa, Olivier Dionne, Dave Hunt, and Sven Santema.

特别感谢 Yang-Hai Eakes , Simon Bouvier-Zappa , Olivier Dionne,Dave Hunt 和 Sven Santema 。

翻译自: https://blogs.unity3d.com/2019/09/05/advanced-animation-rigging-character-and-props-interaction/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值