PuppetMaster学习记录

PuppetMaster是一款用于Unity的物理动画模拟工具,它通过混合模型和动画实现各种表现。文章详细介绍了如何创建布娃娃、配置主要参数以及优化性能的方法,包括减少迭代次数、设置碰撞阈值等。
摘要由CSDN通过智能技术生成

资源地址

AssetsStore:https://assetstore.unity.com/packages/tools/physics/puppetmaster-48977

概述

PuppetMaster是一个用来做物理动画模拟的插件,简单来说就是通过在布娃娃和动画之间做混合,实现在不同需求场景下的不同表现。

使用

创建布娃娃

  1. 在模型上添加脚本BipedRagdollCreator脚本
    在这里插入图片描述

  2. 脚本会自动查找相关的关节点,如果需要修改可以手动替换。
    在这里插入图片描述

  3. 点击"Create a Ragdoll",脚本会在关节点上创建好collider、rigidbody和joint脚本,并显示更多配置
    在这里插入图片描述

主要参数及其含义

名称说明
Weight总重,会根据生物学分配到各个节点上
Optional Bones是否在对应关节上创建collider等控件,不需要的节点可以关闭节省性能
Joints生成Joint的相关设置,只能选择Configurable
Collider对应关节生成Collider的设置
  1. 无论点击"Done"或者"Start Editing Manually"都会将Biped Ragdoll Creator脚本移除,区别是点击"Start Editing Manually"会添加一个Editor下编辑Collider的脚本。

添加PuppetMaster

如果需要布娃娃跟动画共同运行,需要添加脚本PuppetMaster脚本,脚本刚添加完成后,只有以下几个参数
在这里插入图片描述
从参数名字上可以比较好理解他们的含义,配置好两个layer后点击"Set Up PupperMaster"按钮,脚本会展开为:
在这里插入图片描述
PuppetMaster的主要功能是使物理去追踪动画的表现,文档描述如下:

The main purpose of PuppetMaster is to make the Puppet ragdoll physically follow the motion and animation of the animated Target character. It will do so by two means, first is articulating the joints (“Muscles”), the other is pinning the rigidbodies to their targets using AddForce commands (“Pins”). The classes that control the behaviour of the Muscles and handle their strength, pinning and other properties are called “Puppet Behaviours”. The dual rig and the Behaviours will share a common parent GameObject (“Root”) that serves as a container for the PuppetMaster character rig. The kinematic Target character will be mapped to the dynamic Puppet ragdoll by the means of “Mapping”, which can also be smoothly blended in and out for the entire character or for each Muscle separately.

模型的Hierarchy结构也会在"Set Up PupperMaster"之后发生改变,结构如下:
在这里插入图片描述
Behaviours节点下可以放置一些继承自BehaviourBase的脚本,这些脚本可以用来处理一些特定情况的用来动态控制相关权重从而影响模型的表现,插件默认提供了两个组件BehaviourPuppetBehaviourFall,BehaviourPuppet功能比较多,比如可以当角色碰撞到障碍物时改变权重使角色呈现出布娃娃的状态以实现摔倒的表现,BehaviourFall可以处理角色下落时的表现比如说离地面较远时播放一个动画,离地比较近时的动画等,具体使用可以参考链接文档和demo。
PupperMaster节点下为根据之前的配置生成的刚体集合,主要负责物理相关的计算,这么做的原因文档上说主要是为了性能考虑。

The main advantage of using a dual rig over a single character setup is performance. It is much less expensive mostly due to not having the necessity of performing costly transformations with objects that have Colliders attached. The performance win becomes even greater when having to do IK/FK procedures on the target pose. The PuppetMaster can be smoothly blended to run in Kinematic or Disabled mode. The former will simply make the ragdoll kinematic and match it with the target, the latter will completely deactivate the ragdoll when you don’t need it.

Dummy节点就是原来模型的结构。

几个字段的含义:

  • State:共有Alive, Dead和Frozen三种状态,Alive是正常状态表现为物理跟随动画,Dead表现为布娃娃的状态此时动画影响会降低,Frozen状态会停止物理效果。
  • State Settings:主要是三种状态的一些设置,比如说切换过渡的时间,死亡时的肌肉权重等。
  • Mode:共有Active,Kinematic和Disable三种状态。Active表示肌肉都在进行物理模拟,使用addforce等方式使其运动,Kinematic表示肌肉都是Kinematic状态,通过设置位置、角度使其运动,Disable会停止布娃娃效果。
  • BlendTime:Mode切换之间的过渡时间
  • FixTarget:每次循环之前都会将角色的骨骼重置为默认状态,防止出现一些奇怪的表现,只有在动画不包含所有骨骼时需要使用。
  • SolverIterationCount:计算肌肉状态的迭代次数,会影响表现效果和性能。
  • MappingWeight、PingWeight和MuscleWeight的效果参考动图:
    在这里插入图片描述
    可以看到当PinWeight为1时,调整MappingWeight时没有视觉上的效果,当PinWeight为0时,调整MappingWeight可以看到模型在物理骨骼和动画骨骼之间差值,PinWeight随着从0-1调整时物理骨骼会逐渐贴近动画骨骼,Muscle Weight随着调整可以看到动画幅度会受到影响。
    下面的Joint和Muscle Setting包含了一些关节肌肉的统一设置,Individual Muscle Settings包含每个节点的独立设置。
    Prop Muscle设置挂载点,用来实现握剑等目标。

性能

附上官方对于性能优化的使用建议

  • Decrease PuppetMaster “Solver Iteration Count” (changes Rigidbody.solverIterationCount for all the muscles) to the minimum that you can work with. Less solver iterations makes the muscles weaker so you might have to increase PuppetMaster “Muscle Spring”.
  • “Fix Target Transforms” should be switched off when your character is animated at all times.
  • “Visualize Target Pose” costs some performance in the Editor, but not in the built game.
    Leaving “Update Joint Anchors” off improves performance with the cost of simulation accuracy.
  • “Angular Limits” and “Internal Collisions” reduce the workload on the physics engine when disabled.
  • When using BehaviourPuppet, increase PuppetMaster “Collision Threshold”. It determines how strong the collisions must be in order to be processed by the BehaviourPuppet, however, increasing the value will make the puppet’s behaviour jerkier on collision.
  • Reduce the number of muscles. Do you absolutely need 3 spine muscles or the feet or hand muscles?
  • Reducing “Default Contact Offset” in the Physics settings reduces expensive OnCollisionStay broadcasts when using BehaviourPuppet.
  • Increase the “Fixed Timestep” in Project Settings/Time to the maximum tolerable value.
  • Keep your puppets away from each other. Less collisions means much less work for both the Physics engine and the PuppetMaster.
  • Set PuppetMaster mode to “Disabled” for puppets when they don’t need any physics simulation.
  • Set PuppetMaster mode to “Kinematic” for puppets that only need the colliders for collision detection or raycasting.
  • When you do not need to use any Puppet Behaviours nor get a call in case of collisions, comment out the OnCollisionEnter/Stay/Exit functions in MuscleCollisionBroadcaster.cs.
  • PuppetMaster can also run a flat hierarchy ragdoll. Just right-click on the PuppetMaster header and select “Flatten Muscle Hierarchy” from the context menu.
  • 13
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 答:推荐几款 unity 角色插件:1. Unity Standard Assets - 角色动画插件;2. UMA2 - Unity Multipurpose Avatar;3. Unity Character Controller - 角色控制器;4. UMA 2 - Unity Multipurpose Avatar 2;5. Unity 3D Character Creator - 3D 角色创建器。 ### 回答2: 以下是几款推荐的 Unity 角色插件: 1. Playmaker:Playmaker 是一个强大的视觉化编程插件,它可帮助非程序员快速创建角色行为和游戏逻辑。通过简单的拖放操作和图形化界面,您可以创建自定义的角色控制器、状态机、动画过渡和交互逻辑。 2. Final IK:Final IK 是一个用于 Unity 的强大角色动画反向运动学插件。它提供了高级的解算算法,可以实现非常真实的角色动画效果,包括根据物理环境动态调整角色姿势、自动调整脚部在不平坦地形上的位置等功能。 3. UMotion Pro:UMotion Pro 是一个专业的角色动画编辑器,它为 Unity 提供了更多的角色动画控制和编辑功能。借助 UMotion Pro,您可以直接在 Unity 编辑器中对角色动画进行细致的调整、修正和绑定,无需借助外部工具。 4. Behavior Designer:Behavior Designer 是一个功能强大的角色行为设计系统。它提供了广泛的行为节点和状态机,可以帮助您创建复杂的角色行为和 AI。Behavior Designer 还允许您使用 C# 脚本来自定义和扩展角色行为逻辑。 5. PuppetMasterPuppetMaster 是一个高级的角色物理动画插件,它允许您创建逼真的、基于物理的角色动画效果。它使用先进的碰撞检测和约束系统,可以实现角色的真实互动、骨骼碰撞和混合动画。 这些插件都提供了丰富的功能和工具,可帮助您轻松创建和管理 Unity 中的角色角色行为、动画和交互逻辑。无论您是初学者还是有经验的开发者,这些插件都能提供很大的帮助和便利,推动您的游戏开发更进一步。 ### 回答3: 在Unity中,有许多优秀的角色插件可供选择,以下是几款常用的Unity角色插件: 1. Mecanim:Unity的内置动画系统,提供了强大的角色动画控制能力以及多种动画剪辑和过渡方式,能够轻松实现角色动画行为。 2. Final IK:提供了高级的角色IK解算器,可以实现逼真的身体反应和自然的姿势控制,使角色动画更加真实。 3. UMA (Unity Multipurpose Avatar):一个开源的角色生成系统,提供了可自定义的角色模型、衣服、发型等组件,方便快捷地创建各种类型的角色。 4. PuppetMaster:一个强大的物理模拟插件,可以实现高级的角色运动和交互,比如人物之间的搏斗、互动等,使角色表现更加生动。 5. Morph3D:提供了可自定义的角色模型和衣服系统,支持人脸表情、身体形态等多种编辑和动画操作,使角色具备更多的表现力。 6. Opsive Third Person Controller:一个专门为第三人称游戏设计的角色控制器插件,提供了丰富的角色移动、攻击、跳跃等基本行为组件,可快速构建角色控制系统。 以上是几款常见的Unity角色插件,它们各有特点,在不同的项目和需求中选择合适的插件可以提高开发效率和游戏品质。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值