0
votes

I need to read the rotation of an object around each one of its own axis.

I have an object, let's call it controller, free to rotate around its axes. I have three more object and each one of them has to rotate around one of its axis.

When the controller rotates around its own X axis the first object rotates around its own X axis. When the controller rotates around its own Y axis the second object rotates around its own Y axis. When the controller rotates around its own Z axis the third object rotates around its own Z axis.

Each object has to move only with the rotation around the right axis and never with others. It's like I want to divide the transform.rotation of the controller in three different objects.

I cannot choose the rotation of the controller, I can only read it.

1

1 Answers

1
votes

If I understand you question correctly you could do something like that ?

Vector3 localEulers = yourController.localEulerAngles;
Vector3 tmp = localEulers;
tmp.y = 0;
tmp.z = 0;
objectX.localEulerAngles = tmp;
tmp = localEulers;
tmp.x = 0;
tmp.z = 0;
objectY.localEulerAngles = tmp;
tmp = localEulers;
tmp.x = 0;
tmp.y = 0;
objectZ.localEulerAngles = tmp;