- Home /
IF YOUR ANIMATED RAGDOLL CHARACTER FALLS THROUGH FLOOR READ THIS
I only started learning Unity a few weeks ago, and I had this problem with my ragdoll character. No matter what I did, it kept falling through floor. I didn't find anything on forums about this, so I'll leave the solution myself.
The thing is that Animator and Ragdoll can't work at the same time. You should read about Active Ragdoll. Basically, all you need to do is turn on the isKinematic
for all the rigidbodies while animation is on and, when character bumps into something or dies or whatever, turn off the Animator
and set IsKinematic
to false.
Also, English isn't my native language, so sorry if anything. Hope it helps :)
thank you!!
For anyone who wants the script I used:
public class ragdollOnCommand : $$anonymous$$onoBehaviour
{
public GameObject transform$$anonymous$$ain; //your gameobject
public GameObject main; //your main bone
public Collider[] colls;
public bool enable = false;
private void Start()
{
colls = main.GetComponentsInChildren<Collider>();
}
void Update()
{
if (enable)
{
transform$$anonymous$$ain.GetComponent<NPC_behaviour>().enabled = false;
transform$$anonymous$$ain.GetComponent<Animator>().enabled = false;
foreach (Collider r in colls)
{
r.enabled = true;
r.gameObject.GetComponent<Rigidbody>().isKinematic = false;
}
}
else
{
transform$$anonymous$$ain.GetComponent<NPC_behaviour>().enabled = true;
transform$$anonymous$$ain.GetComponent<Animator>().enabled = true;
foreach (Collider r in colls)
{
r.gameObject.GetComponent<Rigidbody>().isKinematic = true;
r.enabled = false;
}
}
}
}
Answer by Banaaani · Jan 26 at 04:21 PM
Thanks, you are a lifesaver. I made it like this:
public Rigidbody[] RigidBodies;
At Awake
RigidBodies = GetComponentsInChildren();
and when you activate the ragdoll
foreach( Rigidbody rb in RigidBodies )
rb.isKinematic = false;
Your answer
Follow this Question
Related Questions
Animate character sitting in a chair 1 Answer
Why does my character fall to his waist? 2 Answers
The "+" icon in Parameters within the Animator is greyed out, what am I doing wrong? 2 Answers
Character animation with Animator isn't working. 1 Answer
Animation From blender to Unity Animator - Import Error 1 Answer