Whenever you see the error:
An object reference is required to access non-static member [...]
This would strongly suggest that you are using a class name where you should actually be using a class instance. In this case, it's saying that you need an instance of Joint
(or rather, FixedJoint
, right?) in order to change its breakForce
value.
To fix this, you will first need to use GetComponent()
to retrieve the instance of FixedJoint
from the current GameObject
, and only then set its breakForce
. For example, if you do this in your Start()
method:
Start() {
GetComponent<FixedJoint>().breakForce = Mathf.Infinity;
}
Hope this helps! Let me know if you have any questions.