1 Reply

There is way too much code here. The "rotation" variable seems to be used for about six different things. In particular, you're applying clamping when you assign rotation on line 13, but then on line 17 (before you've used that clamp rotation for anything!), you reassign rotation to something completely different, with no clamping.

So, that's why the clamping doesn't work... I can't make out what your code is intended to do, but if you simplify it and remove the pointless lines (like line 13), I think you'll be able to fix it.