In general the localRotation is in a quaternion I would think if you wanted the orientation of a particular axis (x, y, or z) to get normalized into 0-1 I would convert to Euler Angle (usually Unity likes to keep between -180 and 180) and then divide by 180. You might need to account for if Unity doesn’t auto keep the angle in that range to make sure it stays there yourself. For example if you have an angle of 270 degrees you would want to change that to -90 degrees so that your math for normalizing could be simple.
Hi thanks for chipping in, I actually dared to try it myself yesterday and did exactly as you said. I indeed got a pole like object rotating in line with the controller. I then decided to try and minimise/restrict the amount the pole/joystick could rotate and this is when problems started. As you mentioned I indeed had trouble with the way eulerAngles respond in Unity, the values jump around and make no sense to a human like me. I literally just cant seem to understand what you’re meant to do with eulerAngles if you want accurate values, especially when your dealing with all 3 axis of rotations coming from the controller. I tried using conditions and clamps but they are no good as the values jump suddenly due to Gimble Locking math, it took me a while to realise also.
I would love a solution if you can think of one? Essentially I want to visually stop the pole/joystick from moving past a particular angle in all directions from it’s centre, like in a plane. Then worry about getting my normalised value. This seems like quite a complex mathematical scenario.
Maybe I should use a position based method with rigidbody and a joint, I kind feel like that loses its excitement and dexterity.
As far as keeping it in the -180 to 180 range it should be straightfoward. If the value goes above 180 subtract 360 and if it goes below -180 add 360.
When it comes to clamping as long as you keep it within the above range and make the adjustments first, it’s usually not difficult to then clamp it further like say 90 degrees or whatever suits your game.