# How to disable spring joint in unity 3d

How can I disable Spring joint in unity 3d, since disabling feature only available in 2d mode, I am not able to find any way to disable it via script

• Have you tried disabling the rigidbody? – Stephan Dec 8 '17 at 0:40

According to this thread on Unity forums, there's no way to disable a spring joint other than to break it and re-connect it. Quoting from the forum thread in Unity:

I was able to create a JointToggler component that finds a joint on the same object and connects/disconnects the connectedBody rigidbody when it is enabled/disabled (like Joints should do by default).

This is the relevant code supplied in the quoted post: using UnityEngine;

public class JointToggler : MonoBehaviour
{
[SerializeField] private Joint joint;
private Rigidbody connectedBody;

private void Awake()
{
joint = joint ? joint : GetComponent<Joint>();
if (joint) connectedBody = joint.connectedBody;
else Debug.LogError("No joint found.", this);
}

private void OnEnable() { joint.connectedBody = connectedBody; }

private void OnDisable()
{
joint.connectedBody = null;
connectedBody.WakeUp();
}
}


I'd normally downvote a question like this for lack of research, since the first google result of disable spring joint unity gave me what I needed, but I couldn't find anything like the sort here, so I'm putting this answer here for archiving purposes.