- Home /
rotate a object around the x axis like other object... stucks at 90 degrees
I really need now some help with this because I wasted already a week with my script because I thought it was something wrong with it but now I found out it was the euler angle 90 degree problem....
ok imagine 2 objects. the 2 objects have 2 children. object 1 has child-A. object 2 has child-B.
now I want that child-B's eulerAngle.x should be the same rotation as the x axis of child-A.
But as I sayed above it stops at 90 degree and then it starts turning backwards till 270 or something... and then it rotates again normal till 90 degree.
Child-B should only rotate around his X axis. and there is the problem....
how do I get a perfect X value of Child-A. please help.
Edit: Here is the code I am using now.... I have 3 bones here because I need then later to rotate the first one 99% the second 66% and the third 33% with the palm.
var forearm1 : Transform;
var forearm2 : Transform;
var forearm3 : Transform;
var palm : Transform;
//Debug:
var palmRot : float;
var forearmRot1 : float;
var forearmRot2 : float;
var forearmRot3 : float;
function Update()
{
var xRotation = palm.rotation.eulerAngles.x;
forearm1.localRotation.eulerAngles.x = xRotation;
forearm2.localRotation.eulerAngles.x = xRotation;
forearm3.localRotation.eulerAngles.x = xRotation;
//Debug
palmRot = palm.rotation.eulerAngles.x;
forearmRot1 = forearm1.localRotation.eulerAngles.x;
forearmRot2 = forearm2.localRotation.eulerAngles.x;
forearmRot3 = forearm3.localRotation.eulerAngles.x;
}
here is the code... I really need help here.
maybe I could get it to work with a workaround like an empty as an referencerotation or something....
its sooo odd... the other axes rotates a full 360 rotation only the x axis does this wierd from 0 to 90 and backwards to 270 thing....
Answer by Harry64 · Jan 01, 2014 at 11:37 PM
I made some progress now... I put now every bone into an empty that where so rotated that now the z axis needed to be rotated... it looks now promising. I get now a full 360 rotation.
still it would be great if there would not be a need to put every bone into an empty.... rotating the bones in Blender would require again more work... if there is no other solution I think then I would need to rotate the bones in Blender...
but this is odd why does every other axis works perfect but only the damn x axis not....
Edit + Answer:
Ok I think the best solution in my case is if I use the emptys or I rearrange the bones in Blender.
It really seems that the X axis is in unity not able to rotate a perfect 360 degree round. I will use the Z axis or the Y axis. they seem to work like they should...
you all can try it for yourself. put an Empty into a unity scene and set it so you see the local rotation. then try to rotate the Empty on the X then Y then Z axis a full round and you will see that the X axis dont work as expected.
Answer by HappyMoo · Jan 01, 2014 at 07:55 PM
Do you really need the angle value or just want to set the same rotation on both childs? Because internally Unity uses Quaternions and when you convert this to Euler angels, you can get strange values.
If you just want the same rotation, just do
childB.transform.rotation = childA.transform.rotation;
child-B should only rotate around its local X axis.... its a bone of a model so I really need the X rotation....
and how does the above code not solve this? what's wrong with it?
it would not solve it... then the model would also rotate to the side and all around... it should only rotate on the transform.localRotation.eulerAngles.x axis... even if the child-A's Y and Z axis are rotated in any other direction....
I would need a value from 0 to 359. If I had such a float var I could just map it right to the bone...
Your answer
Follow this Question
Related Questions
Clarifying the ambiguities of rotation in Unity 1 Answer
Rotation of child object is different in play mode 0 Answers
Why Is Object Rotation Resetting After 90 or -90 Degrees 0 Answers
unwanted rotation on the y and z axes 1 Answer
Rotation Complications + rotation with parents and children? 1 Answer