Control rotation of a configurable joint
Hi everyone, I have been trying to control the rotation between two rigidbodies. I used for a long time hinge joints and their motors, but the results are not good enough. I want to be able to do the same with controllable joints but these seems really hard to master. Here's what I have been trying to do :
private ConfigurableJoint conf;
private float targetAngle;
public float rotateSpeed;
// Use this for initialization
void Start () {
conf = GetComponent<ConfigurableJoint>();
targetAngle = 0;
}
// Update is called once per frame
void Update () {
targetAngle += Input.GetAxis("Horizontal") * Time.deltaTime * rotateSpeed;
Quaternion targetRotation = Quaternion.AngleAxis(targetAngle, Vector3.right);
conf.targetRotation = targetRotation;
}
}
I applied this code to a basic cube with rigidbody linked to another cube with rb by a configurable joint. I set my axis to be around x axis and set every motion locked except the angular x one.
of course, this is not working :)
If everyone has the solution to control these configurable joints, I'd gladly take it. Thanks a lot
Your answer
Follow this Question
Related Questions
Configurable joint don't rotate around the local axis of the rigidbody 0 Answers
Wrong normals when object is rotated and using custom world aligned shader? 4 Answers
Check rotation of an obstacle 0 Answers
Making an object spin on impact 0 Answers
With VR character's rotation is applied twice or double 1 Answer