[Unity] 使用 Animation Rigging 让角色双手正确持握枪械

前言

最近在制作角色状态机时,发现角色不同持枪动作下,握枪位置总是不能统一,例如瞄准时双手已经握住枪械:

 但静态时左手却错位握不住:

 于是找到了使用Animation Rigging做骨骼约束,下面是具体的解决方法:

一、安装Animation Rigging

打开Window/PackageManager/UnityRegistry,搜索Animation Rigging,安装并引入。

 二、布置角色及武器

首先,将角色预制件拖拽至场景,并将武器(双持)放置在角色右手层级下:

 随后点击运行,根据任意个持枪动画来调整武器位置,这里我用了角色IDLE动画,

 

调好当前握枪的姿势后,复制枪械的Transform数值,退出运行,并将数值粘贴给枪械。

此时枪械已经固定在了右手,并且会在动画播放时跟随右手正确的移动。

 三、创建骨骼约束

首先理解Animation Rigging组件的原理,该组件利用了IK(Inverse Kinematics)反向动力学的原理,通过建立骨骼约束来控制你所指定的某个骨骼的运动,例如可将左手骨骼约束在枪托部位,左手将跟随枪托进行移动和旋转,而左手父骨骼的运动将由组件根据IK来控制,从而实现左手自然准确的握枪。

在创建骨骼约束前,需要先创建Rig。在安装Animation Rigging之后,Editor上栏就已经多出了一个Animation Rigging选项:

 选中角色预制件中带有Animator的物体层级,点击上栏Animation Rigging/RigSetup,随后该物体将会多出Rig Builder组件:

 以及该物体的子物体将会多出Rig 1:

 

 此时Rig就已经安装好了(也可以手动创建以上的组件和物体),打开Rig 1会发现该物体下有Rig组件:

 接下来在Rig 1下创建子物体名为Rig_leftHand,并且在该物体下添加Two Bone IK Constraint,此时骨骼约束就创建好了(后续其他的约束也可以在该层级下创建),

随后我们需要绑定骨骼,要指定什么骨骼(图中Root、Mid、Tip)要约束到什么位置上去(图中Target),这里我们需要打开人物骨骼层级,将左手Transform赋值给Tip,随后点击该组件右上属性Auto Setup from Tip Transform:

 点击后组件会自动寻找左手上两层的父骨骼,即左前臂LeftFore、左臂LeftArm(这里也可以手动赋值),并且在Rig_leftHand下创建两子物体target和hint,hint我们暂时用不到,可删除:

随后我们需要在非运行下,把target的transform放到枪械层级下,并拖拽到枪械的枪托位置:

 这样左手的约束点就会随着枪械的移动而移动了,接下来我们点击运行,

 

 此时我们就可以通过调整Rig_leftHand_target的位置来控制左手的托举位置了,调整好合适的角度即可。此后角色在不同的动画下也能准确握枪。

结语

Animation Rigging是个很强大的组件哇,用它甚至不需要预制的动画,也可以自由的控制角色模型,后续镜头瞄准也需使用它,后续有时间再出个教程( •̀ ω •́ )y

关于该组件各功能的介绍网上很多,这里推荐几个:

【unity】Animation Rigging使用整理

Animation Rigging 如何让你的Avatar人物更具灵活性

  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
Requires Unity 5.3.0 or higher. Make Skeleton & Vertex Animations right inside the Unity Editor. [New Online Manual] [v1.9.1] Constraints System Skele: Character Animation Toolssignificantly speeds up animator/indie's animation workflow in several ways: 1. Enable developers to make / modify character animations in UnityEditor. Reduce software switching and tedious import/export/split work 2. [BETA] Integrated Timeline editorGreatly accelerate authoring productivity for complex multi-character scenes (cutscenes / finishing moves / etc) 3. Mesh-Morpher tools to make blendshape-like animations without bones 4. Export skinned meshes and animations as DAE archive 5. Utilize the clips you bought from store, modify them to your needs, convert clip type, export to external softwares, etc. 6. Constraints system working in both edit-mode & game-mode. 7. Spline Editor to edit movement path. ******************* Humanoid rig needs special treatment:Please read the two FAQ posts: (1)How to Edit Humanoid clips? (2)Best workflow for Humanoid models? ******************* Main Features: 1. Make animation for your rigged characters with FK/IK support. flag, stick, dragon, ghost, mech, bird, fish, robot, human... you could manipulate ANY rigged models. 2. Modify animations. Modify Generic/Legacy animations directly; with our converter, you could also modify and export clips you bought from assetstore too. Modify and get the result immediately. 3. Make blendshape-like vertex animations directly in Unity Editor. 4. Integrated with Timeline Editor [BETA]. Edit the cutscene right inplace, and easily integrate with code/fx/audio/gui/etc. 5. Visualize the bone link, the vertices, and bone weights, etc. 6. Reduce the folder size, you don't need to include duplicate meshes for each animation. 7. Make/Save/Load poses on disk 8. Convert MuscleClip(Humanoid clip) to and fro Legacy/Generic clip 9. Generate RootMotion from RootBone curves 10. Export character mesh and character ani
Paperback: 290 pages Publisher: Packt Publishing - ebooks Account (September 29, 2015) Language: English ISBN-10: 1849696365 ISBN-13: 978-1849696364 A detailed guide to the complex new animation tools in Unity, packed with clear instructions and illustrated with original content in the context of a next generation zombie apocalypse adventure game. About This Book Create and export models and animation sequences to Unity from 3ds max and Maya Prepare character models and animation for games using Mecanim’s rigging tools Retarget, adjust, and mix and match motion capture and other animation data Write and edit scripts compatible with Mecanim Animation Controllers Who This Book Is For If you are a Unity developer looking to get to grips with the character animation specific tools, a 3D software user who is new to Unity, or a beginner game developer who is interested in character animation and interaction, this book is ideal for you. Some experience with either the Unity interface or basic 3D coordinates is recommended, but not required. What You Will Learn Learn how to prepare a rigged character model to receive animation within Unity Acquire efficient techniques to refine and optimize motion capture data Retarget animation sequences between different character rigs Discover how to rig a humanoid character and export for use in Unity Script character interaction for a First Person character model Create dynamic animation sequences from scratch using key frame techniques, in a variety of 3D software packages Learn Project Management in Unity Understand how to set up a complex facial rig for speech Set up Animation Controllers with masked states and blend trees to create seamless and additive animation transitions Construct a ragdoll game object and instantiate it in a game Devise Mecanim animation integration for the player and AI driven animation for enemy characters In Detail Game animation for independent developers has taken a giant leap forward with Unity's Mecani

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

好帆果子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值