I’m trying to make a ConfigurableJoint aim in the same direction the camera is aiming in regardless of it’s axis or rotation.
My setup is a main rigidbody with a joint connecting it and another rigidbody.
The joint can be configured in any number of ways, i.e It can be acting as a hinge, or it can be acting as a wheel type joint, depending on what the axis is configured as.
I want to make it so that the joint, no matter how it’s configured or how the “main body” is rotated, always tries to match it’s forward rotation to the camera’s forward rotation.
I’ve tried some simple math code like joint.TargetRotation = Quaternion.LookRotation(Camera.main.transform.forward,joint.axis)
but it’s not giving me the result I want, and I assume it’s not going to be as simple as that
Any ideas on how best to approach this? I’m not a math expert so I feel like that’s what i’m missing.
Physx implementation in unity3d is very poor and configurable joint is best example of it.
Let me tell you - you will probably not be able to pull it off.
TargetRotation is in joint space, joint space is in physx right-handed coordinates, to make things worst you have to take into account that you can set primary and secondary axis for a configurable joint.