我正在尝试在行走动画和布娃娃下落过程之间进行逼真的过渡。基本上,当调用“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;
}
}