I have this script attached on a gameobject with a Hinge Joint.
When click up/down, the value is changed. The debug shows the new value, but nothing happens on Inspector and gameobject still doesn’t move. If I put same values by inspector, works. What to do?
public class Mover : MonoBehaviour
{
JointMotor motor;
void Start()
{
motor = GetComponent<HingeJoint>().motor;
motor.targetVelocity = 5;
}
void Update()
{
if (Input.GetKeyDown(KeyCode.UpArrow))
motor.force += 2f;
else if (Input.GetKeyDown(KeyCode.DownArrow))
motor.force -= 2f;
Debug.Log("Force:" + motor.force);
Debug.Log("Vel:" + motor.targetVelocity);
}
}