- Home /
Stops working in build : disabling all colliders and rigidBodies in a character (ragdoll)
Hello Folks ! : D
I am working on a Ragdoll that appears when the enemy dies. The idea is do desactivate all of the colliders and rigidBodies in a character, so the ragdoll stays in a fixed position and stops moving around so much.
The thing is, I have a code for this that should work, but doesn't. See, when I instantiate a ragdoll, it works just fine, but if I put a ragdoll in the scene manually, or if I build the game, I end up having the two arms not affected, so they just wobble around weirdly while the rest of the body stays put ( not just a single chain, but also both legs).
Here's the code :
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class RagdollStopCalcul : MonoBehaviour {
//private List<Collider> CollList;
private float timer = 0;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
timer += Time.deltaTime;
if (timer >= 3)
{
foreach (Collider col in gameObject.GetComponentsInChildren<Collider>())
{
Rigidbody rigidyrigidy;
rigidyrigidy = col.GetComponent<Rigidbody>();
rigidyrigidy.isKinematic = true;
col.enabled = false;
}
}
}
}
Your answer
Follow this Question
Related Questions
problem with 2d ragdoll to animation 0 Answers
Need help with fixing position of Colliders for a Ragdoll 1 Answer
How to fix Colliders flying off after activation? 1 Answer
Ragdoll help 0 Answers
Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers