I am trying to make a script in javascript to bind a-d to rotate my cameras x and y axis in an specific matter but it does not seem to work. please keep in mind that i am not an experienced programmer.,So i am creating a program in javascript to rotate a camera and my script only causes an error message and i dont know why.
Instead of CameraRotation[1] - 2; you should write CameraRotation[1] -= 2;
I’m not exactly sure what happens internally, with the first one, but using the -= operator (or +=) is acutally getting the value, making it lower and then assigning it back.
e.g.
CameraRotation[1] -= 2;
is the same as
CameraRotation[1] = CameraRotation[1] - 2;
And another thing, the indexation of arrays starts at 0 - as in, the first variable is indexed by 0, the second one is indexed by 1 and so on.
So, with CameraRotation[1] you are accessing the transform.eulerAngles.y component of the array and not transform.eulerAngles.x.