Error when setting Rotation
Hi, I get an error message, which i do not really understand. Screenshots here:
https://gyazo.com/935810c34b81ecb0cada8f438a979316
https://gyazo.com/fbfe7ced30a317067c490b9060b62609
"Cannon" is a Transform.
Can Someone help me with this?
Thank you, Zerzuskan
Answer by FeeeshMeister · Nov 23, 2016 at 03:35 AM
Cannon.rotation does not exist as euler angles, but cannon.transform.rotation does, but I think that Cannon.transform.rotation.eulerAngles is readonly (Meaning that it cannot be changed), so if that does not work, use Cannon.transform.eulerAngles. Because the rotation transform is stored as a quaternion, the code gets the quaternion and converts it into euler angles, so it is trying to return the new euler angles, while you are trying to give it euler angles, so it returns an error. Sorry if this is difficult to understand, it is kind of hard to explain, just use Cannon.transform.eulerAngles in place of Cannon.transform.rotation.eulerAngles.
Answer by Zerzuskan · Nov 23, 2016 at 08:09 AM
cannon is a transform variable, so this should not be the problem(you cant see ist in the screenshot, so i wrote it in the question).
The second part:
So because rotation works as quaternion i cant use rotation.eulerangles to store an new rotstion as Euler angles? Like rotation.eulerangles is readonly? Can i convert the Vektor3 to an Quaternion somehow?
@Zerzuskan , I thought when you said, "Cannon is a transform" that was an error. Use Cannon.eulerAngles ins$$anonymous$$d of Cannon.rotation.eulerAngles, if that does not work, let me know by saying @Feeesh$$anonymous$$eister at the beginning of the question. Cannon.eulerAngles is of the type eulerAngles, which is like a vector3, but the values are clamped to 360°.