How to deal with stupid rotation system?
Hi!
Simply, I want to add a rotation to an existing gameobject's rotation.
For example, I have (0, 0, 50) and I want it to be added to rotB (0, 0, 0).
I've tried this code:
rotB *= Quaternion.Euler (0, 0, 50);
But the result is so weird, something like (2.53543, 7.54353534536, 50).
Any ideas ?
Answer by markdavidmorris · Jun 15, 2016 at 04:53 PM
One other thing to make sure of, look closely at the inspector position x, y, and z values. sometimes it cuts off the scientific notation at the end of the float, so 2.53543e-10 looks like 2.53543, when it's actually essentially 0, but some floating point rounding made it look non-zero. Just something to check.
O$$anonymous$$, this is the measure of the weird angle.
Does this mean actually 0 in-game?
Answer by markdavidmorris · Jun 15, 2016 at 03:59 PM
Have you tried: rotB = Quaternion.Euler (rotA.eulerAngles.x, rotA.eulerAngles.y, rotA.eulerAngles.z + 50f);
Have you tried printing the euler values right before and after this operation to make sure nothing else is changing the x and y eulers?
That's right, what you're seeing is a rounding error that is essentially 0 in the game. Pretty much the only way this would cause a problem is if you're doing some kind of if(rotB.eulerAngles.x == 0f) check. Otherwise, you shouldn't notice any difference between this and perfect 0f.
Your answer
Follow this Question
Related Questions
.rotation doesn't seem to work, can't shoot projectile at mouse coordinates 0 Answers
Searching a function to get the rotation of one Vector3 in relation to another 1 Answer
Limiting gameObjects rotation on Zaxis giving wierd results 1 Answer
How do I limit an object to rotate back and forth between 2 angles? 1 Answer
Problems with limiting angles 1 Answer