visual-studio - 在 Unity 中优化 Ragdoll 行为
问题描述
我正在尝试在行走动画和布娃娃下落过程之间进行逼真的过渡。基本上,当调用“DoRagdoll”函数时,我将之前的力从行走动画添加到所有刚体组件的质量。然后我停用动画组件并为所有刚体打开重力。它有效,但看起来仍然有点奇怪。我已经尝试了很多类似 Unity 文档站点的方法来解决布娃娃的问题,并且我还尝试了不同身体部位的关节。我使用内置系统来创建布娃娃。关于如何改进过渡或如何创建更逼真的布娃娃的任何想法?
void Awake()
{
rbs = GetComponentsInChildren<Rigidbody>();
DoRagdoll(false);
foreach (Rigidbody rb in rbs)
{
rb.useGravity = false;
//rb.isKinematic = true;
}
}
public void DoRagdoll (bool isRagdoll)
{
if (isRagdoll)
{
foreach (Rigidbody rb in rbs)
{
rb.AddForce(rb.mass * rb.velocity, ForceMode.Impulse);
}
}
GetComponent<Animator>().enabled = !isRagdoll;
if (isRagdoll)
{
foreach (Rigidbody rb in rbs)
{
rb.maxDepenetrationVelocity = 0.01f;
rb.useGravity = true;
//rb.isKinematic = false;
}
NavMeshAgent agent = GetComponent<NavMeshAgent>();
//GameObject.FindGameObjectWithTag("pelvis").GetComponent<PelvisPush>().PushPelvis();
rbSlowdown = true;
ragdollOn = true;
}
else
{
GetComponent<NavMeshAgent>().speed = GameObject.FindGameObjectWithTag("root").GetComponent<OldmanMovement>().movSpeed;
foreach (Rigidbody rb in rbs)
{
rb.useGravity = false;
//rb.isKinematic = true;
}
ragdollOn = false;
}
}
解决方案
推荐阅读
- reactjs - React PropType 检查动态对象
- javascript - 在动态生成的 div 上应用 touchstart
- scala - Scala 中 DSE Cassandra 上的 Spark SQL 查询
- ember.js - 如何减少 Windows 10 上的 ember 应用程序构建时间,但它在 ubuntu 上运行良好
- sql - Why doesn't cross join work in my query?
- javascript - 函数式编程多态性
- visual-studio - 打开 GitHub 项目时如何让 Github 以管理员身份打开 Visual Studio?
- git - 如何签出旧提交并将其推送到当前分支?
- android - 设备上的android仪器测试删除应用程序数据
- extjs - extjs 为更多列更改网格颜色单元格