Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Doneyes · Sep 22, 2012 at 11:49 PM · animationcharacterragdolljoint

How do I disable / enable a character joint?

I am trying to go from animation, to ragdoll, then back to animation. I can do this if I can enable / disable character joints. How can I accomplish this? I don't see a little check box.

Comment
Add comment · Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image reptilebeats · Sep 23, 2012 at 12:33 AM 1
Share

use is kinematic on the rigidbody

avatar image Doneyes · Sep 23, 2012 at 12:53 AM 0
Share

I tried that, and the character joints still react.

avatar image reptilebeats · Sep 23, 2012 at 01:00 AM 1
Share

disable it via script on a collision or when you want the ragdoll effect to happen. for example for something like a fallout type of death just write a script which says when health reaches zero disable iskinematic on all rigidbodys with joints.

avatar image Doneyes · Sep 23, 2012 at 01:10 AM 0
Share

I am saying that when is kinematic = true, the body doesn't fall, but the joints still react and dangle. Edit: I put it in every body and now it works! So I have to put it in every bone or is there a possible way around it?

avatar image reptilebeats · Sep 23, 2012 at 01:18 AM 1
Share

every rigidbody with a joint connected to the body needs to have iskinematic set to true, you could make an editor script to do this for you but would be pointless unless you were always switching between them.

Show more comments

3 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by Panzermjau · Dec 21, 2014 at 10:05 AM

From what I've found the joint still applies its constraint even if rigidbody.isKinematic is set to true.

I solved it by destroying the joints on startup, then recreating them to enable the ragdoll. Not very elegant, but it seems to work ok.

 public class RagdollEnabler : MonoBehaviour {
 
     private List<CharacterJointDisabler> _jointDisablers;
     
     private void Awake () 
     {
         CharacterJoint[] characterJoints = transform.GetComponentsInChildren<CharacterJoint>();
 
         _jointDisablers = new List<CharacterJointDisabler>();
         for(int i=0; i<characterJoints.Length; ++i)
         {
             characterJoints[i].collider.enabled = false;
             characterJoints[i].rigidbody.isKinematic = true;
 
             CharacterJointDisabler disabler = characterJoints[i].gameObject.AddComponent<CharacterJointDisabler>();
             disabler.CopyValuesAndDestroyJoint(characterJoints[i]);
             _jointDisablers.Add(disabler);
         }
     }
 
     public void ActivateRagdoll ()
     {
         rigidbody.constraints = RigidbodyConstraints.None;
 
         for(int i=0; i<_jointDisablers.Count; ++i)
         {
             _jointDisablers[i].collider.enabled = true;
             _jointDisablers[i].rigidbody.isKinematic = false;
 
             _jointDisablers[i].CreateJointAndDestoryThis();
         }
     }
 }
 
 
 public class CharacterJointDisabler : MonoBehaviour 
 {
     private Rigidbody ConnectedBody;
     private Vector3 Anchor;
     private Vector3 Axis;
     private bool AutoConfigureConnectedAnchor;
     private Vector3 ConnectedAnchor;
     private Vector3 SwingAxis;
     private SoftJointLimit LowTwistLimit;
     private SoftJointLimit HighTwistLimit;
     private SoftJointLimit Swing1Limit;
     private SoftJointLimit Swing2Limit;
     private float BreakForce;
     private float BreakTorque;
     private bool EnableCollision;
 
     public void CopyValuesAndDestroyJoint(CharacterJoint characterJoint)
     {
         ConnectedBody = characterJoint.connectedBody;
         Anchor = characterJoint.anchor;
         Axis = characterJoint.axis;
         AutoConfigureConnectedAnchor = characterJoint.autoConfigureConnectedAnchor;
         ConnectedAnchor = characterJoint.connectedAnchor;
         SwingAxis = characterJoint.swingAxis;
         LowTwistLimit = characterJoint.lowTwistLimit;
         HighTwistLimit = characterJoint.highTwistLimit;
         Swing1Limit = characterJoint.swing1Limit;
         Swing2Limit = characterJoint.swing2Limit;
         BreakForce = characterJoint.breakForce;
         BreakTorque = characterJoint.breakTorque;
         EnableCollision = characterJoint.enableCollision;
 
         Destroy (characterJoint);
     }
 
     public void CreateJointAndDestoryThis()
     {
         CharacterJoint characterJoint = gameObject.AddComponent<CharacterJoint>();
 
         characterJoint.connectedBody = ConnectedBody;
         characterJoint.anchor = Anchor;
         characterJoint.axis = Axis;
         characterJoint.autoConfigureConnectedAnchor = AutoConfigureConnectedAnchor;
         characterJoint.connectedAnchor = ConnectedAnchor;
         characterJoint.swingAxis = SwingAxis;
         characterJoint.lowTwistLimit = LowTwistLimit;
         characterJoint.highTwistLimit = HighTwistLimit;
         characterJoint.swing1Limit = Swing1Limit;
         characterJoint.swing2Limit = Swing2Limit;
         characterJoint.breakForce = BreakForce;
         characterJoint.breakTorque = BreakTorque;
         characterJoint.enableCollision = EnableCollision;
 
         Destroy(this);
     }
 
 
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by aldonaletto · Sep 23, 2012 at 01:28 AM

You can use a simple function to enable/disable the rigidbodies:

var rigids: Rigidbody[];

function Start(){ rigids = GetComponentsInChildren.< Rigidbody>(); }

// make all rigidbodies kinematic (true) or not (false):

function MakeKinematic(onOff: boolean){ for (var rb: Rigidbody in rigids){ rb.isKinematic = onOff; } }

Use MakeKinematic(false) to enable the ragdoll, and MakeKinematic(true) to disable it.
Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Doneyes · Sep 23, 2012 at 02:09 AM 0
Share

The character wont fall or react to forces now though. How can I get around that?

avatar image reptilebeats · Sep 23, 2012 at 02:14 AM 0
Share

if you mean the character just stays in mid air when u hit play this is because you need to have one rigidbody set to false on iskinematic the parent object of the character or main root bone

avatar image Doneyes · Sep 23, 2012 at 02:21 AM 0
Share

I do that and it still floats because there's a lot of other rigid bodies in there too.

avatar image reptilebeats · Sep 23, 2012 at 02:33 AM 0
Share

should be on the main root bone, their shouldn't be any other rigid bodies on a parent except for its children. their shouldnt be joints either on this one, only joints attached to it

avatar image reptilebeats · Sep 23, 2012 at 02:35 AM 0
Share

try attaching some cubes together with joints and have the main one's iskinematic set to false whilst the rest are set to true

avatar image
0

Answer by TheHgang · Jun 07, 2020 at 10:06 AM

Plz check Rigidbody iskinematic property and save urself lot of trouble

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Character Joints, twist and swing 0 Answers

How can I create a ragdoll ot of character joints? 0 Answers

Configurable joints rotating at a certain angle 2 Answers

How should I make a animate fully physics based Active Ragdoll? 0 Answers

How can I make a ragdoll on command? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges