If mouseY gives a value between 1 and -1 then why when I assign it to xRotation variable it gives me a value over 1 (It is clamped so it will give me a value between 90 and -90) I keep thinking that it should give me a value between 1 and -1 since the value of mouseY is always between 1 and -1. I have tried to debug them both and I could not understand it, at first I thought that it because of the mouseSenstivty variable and I debuged it without it and I found nothing.
Thank you, I understand now that the value will not be in the range of -1 and 1 since the axis is mapped to the mouse it will give me a value multiplied by the axis sensitivity, but why when I assign it to xRotation the value changes? It returns the actual rotation of the unity unit world. I have this script on the Main Camera and its x rotation is the same as the xRotation variable.
Thank you again, and sorry if my question is weird.
I’m not sure exactly what you mean by this, but your code is not assigning the mouse input value to xRotation. It is doing this: xRotaition -= mouseY;which is equivalent to this:xRotaition = xRotaition - mouseY;
I was confused why is the result completely different than the mouseX variable when it should return the value of xRotation - mouseX. I just do not understand the value of xRotation and why is it like that why it is not a small number? How is it exactly the same as the x rotation of the camera?
as stated, it is exactly because of -= which does something completely different then how you treat mouse.x
namely, it reduces the existing value each frame by mouseY, for no particular reason
unlike mouseX which is simply set to a value and passed further
unroll this in your mind, let’s say you had 0.5 and 0.2 as your mouseX/Y:
frame #1: 0.5, 0.2 come in → xRotaition is now -0.2, and 0.5 is passed through
frame #2: 0.5, 0.2 come in → xRotaition is now -0.4, and 0.5 is passed through
frame #3: 0.5, 0.2 come in → xRotaition is now -0.6, and 0.5 is passed through
frame #4: 0.5, 0.2 come in → xRotaition is now -0.8, and 0.5 is passed through
frame #100: 0.5, 0.2 come in → xRotaition is now -20.0, and 0.5 is passed through
you’re welcome. I’m glad it was useful. in general this “unrolling” practice can help you a lot with designing particular behaviors, at least until you get a better grasp of the system, then you get to level up significantly, when you can just look at this expression and know exactly what to expect from it.