Hi guys, I’ve searched for days but haven’t quite found the answer yet; sorry if it’s already out there.
I’m trying to make a script that will behave like the wire parameters in 3D Max. For those unfamiliar with wire parameters, it lets you link Obj1’s X Rotation to Obj2’s Y Position for example. This allows me to rotate Obj1 to raise or lower Obj2. You can also link position to position and rotation to rotation.
That being said, matching position to position per axis is fairly simple. Where I’m having trouble is with the rotations; specifically the X rotation. Say I have a MasterObj and a SlaveObj. If I link the X Rotations, when I rotate the MasterObj, the SlaveObj ping-pongs between -90 and 90 degrees, boosting the Y and Z axes to 180. No matter if I use Euler angles or Quaternions.
if (followRotationX == true){
rotX = target.transform.localEulerAngles.x;
}else{
rotX = transform.localEulerAngles.x;
}
if (followRotationY == true){
rotY = target.transform.localEulerAngles.y;
}else{
rotY = transform.localEulerAngles.y;
}
if (followRotationZ == true){
rotZ = target.transform.localEulerAngles.z;
}else{
rotZ = transform.localEulerAngles.z;
}
Vector3 rot = new Vector3(rotX,rotY,rotZ);
transform.localEulerAngles = rot;
For now, all I want is for my SlaveObj to behave like if it was parented to my MasterObj, all while having control over whether I want it to follow the position and rotation and on which axes.
Basically, this : http://constraints.path-o-logical.com/ but allowing me to link rotations and position, cross-axis (RotY to RotZ, PosX to PosZ, etc.)
Anyone have any wise advice? Thanks !
P.S. I’m a 3D artist who dabbles in code sometimes…