Hey, I want to rotate an object to a sertant value, but I can’t make the rotation stop again. So when it has rotated to the value of 30 on the y rotation I want it to stop again. The method I’m using to rotate looks like this:
It's because transform.rotation isn't stored as an 'xyz euler' rotation representation- it's a quaternion, and it basically doesn't work the way you think it does. Try using
transform.rotation.eulerAngles
instead, since it's more like what you are used to.
Of course, I'm pretty sure there are much better ways of rotating an object over time. For example, this code isn't frame-rate independent, so the speed of rotation will change as the framerate increases and decreases. But that's not the topic of your question, so I won't get into that.