Configurable joint around 2 axis

Hi every one, I would like to rotate a configurable joint around 2 axis.
I actually do this :

var configurableJoint = GetComponent(ConfigurableJoint);
configurableJoint.targetRotation= Quaternion.AngleAxis( angle, Vector3.right );

The “Axis” of my joint is : X : 0 - Y : 1 - Z : 0.

So the object rotatate around Y with the "angle’ variable.

Now I want to rotate it around Y and Z simultaneously.
The “Axis” of my joint become : X : 0 - Y : 1 - Z : 1.
But I don’t understand how to script it (the angle can be different around Y and Z)

Thanks for help :wink:

Nobody can help me ?

I’m experimenting with joints too. I’m trying to use a ConfigJoint as a constraint. I’m just trying to figur it out, so I might be no real help.

You can set the local coordinate system of the joint by filling out the Axis and Secondary Axis in the Inspector or in your script assigning Vector3 values to ConfigurableJoint.axis and ConfigurableJoint.secondaryAxis. The third axis will be orthogonal to the other two.

Thanks, but how could I change the rotation around Y and Z with the “targetRotation” ?

So you have an object anchored to a point with the joint. Do you want it to be able to rotate around the point around the Y and Z axis, or do you want it to rotate the object?

I can try to help but you shoud read these though:
http://unity3d.com/support/documentation/Components/class-ConfigurableJoint.html
http://unity3d.com/support/documentation/ScriptReference/ConfigurableJoint.html

I won’t be able to provide you more information, I can only try to interpret it.

Thanks, I’ve learned this documentation.
I want to rotate my object around the Y and Z axis of the joint (now around the transform of the object).

I can rotate the objet around the Y axis of the joint with this :
var configurableJoint = GetComponent(ConfigurableJoint);
configurableJoint.targetRotation= Quaternion.AngleAxis( angle_y, Vector3.right );
If the axis of the joint is : X : 0 - Y : 1 - Z : 1;

If i change my axis to X : 0 - Y : 0 - Z : 1, my objet rotate around Z

Now I want to rotate it around Y of 30° and around Z of 10° per example.
I really don’t know how to do it :frowning:

Please, I really nedd help !

ConfigurableJoints don’t do exactly what you think they do based on the multiple axis provided, unless you use dummy objects. At least that’s my experience with them. I’ve pushed them to their limits of usefulness for me, but I’m sure they’re capable of MUCH more. However for me they were most useful in conjunction with Dummy objects, when they become incredibly powerful joints. And seemingly VERY efficient in terms of their CPU overhead.

Dummy Objects are place holders, providing a center for your end of joint connection with your object. By this I mean create an empty object in the EXACT coordinate center of the object you wish to rotate.

The easiest way to make it absolute center of your object is to create the empty object (from now on referred to as the Dummy) on screen anywhere. Then make it a sub object of the object you want to control (Where Object B is the one you want to control, Object A is the object you’ve currently got B connected to via the Configurable Joint) Once your Dummy object’s a sub object of Object B, set it’s transform position to 0,0,0 as it’s position is now relevant to the object you’ve made it a child of. (this is all in the Hierarchy panel of the editor, not in code, I assume you’re making a prefab or object stack in the editor for all this, that you can then play with by code later)

Now in the Hierarchy panel drag the Dummy (empty object) out from it’s position as a child, into open space in the Hierarchy panel. This makes it it’s own boss again, but it retains it’s position relevant to your object, only now in world transform terms rather than relative to your object.

Now make Object B’s configurable joint connect to your Dummy object, releasing it from it’s connection to Object A. Now give your new Dummy object a configurable joint to your Object A. You’ve now got the power you imagined possible with configurable joints. And then some!

To start your experiments, lock down your Dummy objects connection to Object A on every position and rotation axis. And then play with Object B’s connection to the Dummy. You’ll probably get the right result this way, but if you don’t, you can focus on one axis with your Dummy Object’s connection to Object A, and one with Object B’s connection to the Dummy Object. And that SURELY will get you your desired result.