So basically I have a spaceship that rotates left and right when the user presses the respective key.
I use Mathf.Clamp to clamp the rotation value between 240 and 300, it starts at 270. My problem is that pressing right it stays locked at 270 (the starting position). Pressing left it will properly go to 240 and back to 270. Sometimes it will go past 270 and lock at 300 but its very unpredictable and happens when pressing the opposite key! So it’s kind of half working. I really can’t see why it’s doing this and it seems pretty simple code. Hope someone can help, thanks!
Okay, so referring to your two messages, I have removed my if statements(good riddance! Thanks for the tip). Left and right Translate and Rotate are working fine, but when I try and clamp the Euler rotation it stays locked at 270(starting position). Here is my new code.
IT’S WORKING! Thank you Not_Sure! I simply moved “Vector3 rot = myTrans.eulerAngles;” To after the Rotate happens and it’s working perfectly, with improved smoothness thanks to removing the ifs.