Problem - It seems these two ‘operations’ cannot be performed in succession. All I get is the second part (AddTorque). My guess is Unity combines the entire thing and runs it together at the end of the FixedUpdate. Can I overcome this somehow or is that just how it works?
private void FixedUpdate()
{
JointDrive jd1 = new JointDrive
{
positionSpring = Mathf.Infinity,
maximumForce = Mathf.Infinity,
positionDamper = 50f
};
bike_CJ.slerpDrive = jd1;
bike_CJ.xMotion = ConfigurableJointMotion.Locked;
bike_CJ.yMotion = ConfigurableJointMotion.Locked;
bike_CJ.zMotion = ConfigurableJointMotion.Locked;
bike_CJ.targetRotation = Quaternion.AngleAxis(30 * lean, bike_TR.forward); // lock the joint, rotate it with target rotation force
JointDrive jd2 = new JointDrive
{
positionSpring = 0f,
maximumForce = 0f,
positionDamper = 0f
};
bike_CJ.slerpDrive = jd2;
bike_CJ.xMotion = ConfigurableJointMotion.Free;
bike_CJ.yMotion = ConfigurableJointMotion.Free;
bike_CJ.zMotion = ConfigurableJointMotion.Free;
bike_RB.AddTorque(Vector3.up * 10, ForceMode.Impulse); // disable target rotation force, unlock the joint, rotate it with AddTorque
}