I want to rotate an object around it’s Z axis as long as a button is pressed. I need to rotate it from 0f to -40f and not further. How would I do that? My current code isn’t doing the trick and I also think it won’t work accurate.
I edited my post, did you try the new or the old?
if that never stop with this code, try delete the 0.1f and replace with 10f for see if the probleme is the precision, also set the speed lower.
I am also seeing another issue why I am failing. During setup, I have the Z rotation of the object at 0. But when starting the game in Unity, eulerAngles.z returns me 359.735 or similar values… Is there a way to read the actual 0 that is also still shown in the Inspector during runtime?
No problem. I was almost not going to say anything, I knew the other solution would work with a few changes. Just thought I’d share it as another option/thought
Your solution does work but it has one issue. When I do not use the method, the Z rotation of the object is now 0 to world. It looks like it’s not parented any more.
For better understanding: It’s an airbrake of an aircraft. It would now always rotate parallel to the ground on Z axis, no matter the rotation of it’s parent [the aircraft].