1

I have a ragdoll. I want to increase the scale of this ragdoll in game mode. But when I increase the scale ragdoll' bones mingle and drool. How can i prevent this from happening? Related pictures below. Normal Scale 3x Scale

Murat Ugur
  • 13
  • 4

1 Answers1

1

Welcome to StackOverflow. After a quick search on Google and I've found an answer for you: http://answers.unity.com/answers/1556521/view.html

TL;DR: joints calculate anchor only on start, but are never updated later. To make them update later, just reassign them

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];
         }
     }
 }

Just make sure you do this reassign only when needed as it will hurt your performance...

tsvedas
  • 1,049
  • 7
  • 18
  • 2
    You are great! I searched on Google but couldn't find it. I didn't realize it was about Joint. You helped me a lot, thank you very much! – Murat Ugur Aug 05 '21 at 10:04