# FixedJoint error in Unity?

I get the following error every time I run the code:

error CS0120: An object reference is required to access non-static member UnityEngine.Joint.breakForce'

Joint.breakForce = Mathf.Infinity;


How can I properly write this? I want to set the break force to Mathf.Infinity to render the joint unbreakable.

Looks like you just need to reference the object

private FixedJoint joint;
void Start()
{
joint = GetComponent<FixedJoint>();//assuming the joint and script components are attached to same gameobject.
joint.breakForce = Mathf.Infinity;
}


Here Joint is a class. If you have an object called Joint, rename it to lowercase joint, since that is the proper naming style in C#. Your code then should become:

joint.breakForce = Mathf.Infinity;

• And how do I properly write this? FixedJoint.breakForce = Mathf.Infinity; – That's me. Oct 28 '15 at 13:43
• Because I get error CS0103: The name joint' does not exist in the current context – That's me. Oct 28 '15 at 13:43
• Because there should be an object called 'joint', which you want to make unbreakable, but here you're trying to set the break force to a class called 'Joint' which doesn't make sense. Adding more context code into your question may help resolving the issue. – Maks Maisak Oct 28 '15 at 13:47
• My other question and what I want to achieve: stackoverflow.com/questions/33389802/… – That's me. Oct 28 '15 at 13:53
• Also, read the comments in the other question. – That's me. Oct 28 '15 at 13:54