Hi I need to change breakforce in one of objects. Except it has multiple fixedjoints.
rigidbody.hingeJoint.breakForce = 0.0f;
Following the structures in unity only shows a single possible joint? Since they are not named, how to do I find it?
Hi I need to change breakforce in one of objects. Except it has multiple fixedjoints.
rigidbody.hingeJoint.breakForce = 0.0f;
Following the structures in unity only shows a single possible joint? Since they are not named, how to do I find it?
You can use GameObject.GetComponents to get all components of a particular type attached to an object. The manual page actually has an example involving joint components.
Using GetComponent will give me a list alright. But I will have no idea which joint it is it has no name.
Can you identify the hinge by its connectedBody property (ie, which object the hinge is joined onto)?
I could do that, but that’s not a good solution. The joints really should be either named. I could even just manually rip through the list first time and find the index of the joint I am interested in. But as soon as I make a change in the inspector. Or delete and recreate the joint later on. I break the code.
For now I am just counting off the index like I said above, and just being aware not to mess with the inserted joints after wards.