- Home /
Question by
Aertu · Dec 20, 2016 at 03:23 PM ·
valuejointrangeproperties
Set minimum/maximum value for Joint properties
Hello
How to define min/max value for this example? Im changing distance of DistanceJoint2D per Keyboard but need min value to be 2 and max value 10 because of the object leaving the gaming screen. Im new in Unity and this may be a very basic question, so I would also be happy about a hint and I will google myself. Thanks
public DistanceJoint2D playerJoint;
void Start()
{
playerJoint = GetComponent<DistanceJoint2D>();
playerJoint.distance = 3;
}
void Update()
{
if (Input.GetKey(KeyCode.Q)) {
playerJoint.distance += 1.0f;
}
if (Input.GetKey(KeyCode.E)) {
playerJoint.distance -= 1.0f;
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612103049im_/https://answers.unity.com/themes/thub/images/avi.jpg)