- Home /
Joint system scale problems
Hello! I'm having some issues with a joint system I built and I can't figure out how to troubleshoot or fix it.
I have a hand I set up to be an active ragdoll, the joint system has a parent object to make it easy to move it around as a whole.When I hit play it looks like this- https://i.gyazo.com/d51ce9c4cedd1ca35552d28bd9d06264.gif
It's not perfect but it works well enough for now. However, when I scale my parent object to be smaller the entire behavior of the joint system changes. When I scale it smaller and hit play the same exact system with 0 changes behaves like this- https://i.gyazo.com/b2030833ec5641e79a2c711a367592a1.gif
I am using configurable joints and capsule colliders. The configurable joint contains an option for "Configured in World" which is toggled to false. There is no script or code on this object. If you have any ideas on how to fix this I would greatly appreciate it. Thank you
Answer by RichardRevesz · Sep 25, 2018 at 01:24 PM
Dude, I have been struggling this for a while now, and finally I have figured it out. Not sure if you still need it, but here it is anyways.
So the problem seems to be that the physics system calculates the anchors and connected anchors at the start, but does not update them later, which is fine, as long as the scale is the same.
But when you scale it, the joint system stays at the original size thus the model falls apart.
What you need to do is save the anchor and connected anchor positions, and update it whenever you scale it. (It is in local space, so no need to scale it).
Don't forget to disable Auto Configure Connected Anchor!!
My script does it in every update:
Transform[] children;
private Vector3[] _connectedAnchor;
private Vector3[] _anchor;
void Start()
{
children = transform.GetComponentsInChildren<Transform>();
_connectedAnchor = new Vector3[children.Length];
_anchor = new Vector3[children.Length];
for (int i = 0; i < children.Length; i++)
{
if (children[i].GetComponent<Joint>() != null)
{
_connectedAnchor[i] = children[i].GetComponent<Joint>().connectedAnchor;
_anchor[i] = children[i].GetComponent<Joint>().anchor;
}
}
}
private void Update()
{
for (int i = 0; i < children.Length; i++)
{
if (children[i].GetComponent<Joint>() != null)
{
children[i].GetComponent<Joint>().connectedAnchor = _connectedAnchor[i];
children[i].GetComponent<Joint>().anchor = _anchor[i];
}
}
}
I hope you find it useful. Best, Richard
Thank uh ! Its Working Now I can Change $$anonymous$$y Active Ragdoll Scale Runtime One change : Called Update Block only once Whenever You Change the Scale You do not need to Calling it Continuedly
Answer by FortisVenaliter · Feb 10, 2017 at 09:59 PM
When you scaled your hand, did you scale the mass in the rigidbody(s) to match?
If you don't, the forces (particularly gravity) will appear to have a larger magnitude.
I currently have the rigid bodies set to not use gravity. So that shouldn't be an issue. Also I didn't think the forces would be different since I have the configurable joints set to work in local space.
I attempted the scaling of the rigidbody mass as you suggested, to match the overall decrease in scale of the parent transform. However the behavior is exactly the same as when the mass was not changed.
Your answer
Follow this Question
Related Questions
How can I make a configurable joint behave like a spring joint? 0 Answers
Violent shaking when using position drive in Configurable Joints 1 Answer
Getting a configurable joint to point at another object 2 Answers
Configurable Joint attaches at different points 0 Answers
How target rotation and target angular velocity work in configurable joint ? 1 Answer