hi
i am manipulating the main camera position through a c# script
i want to change the camera position and rotation through basic keys like up, down, etc
that i manage to do / achieve, but the outcome is slightly not what i desire
i use:
Vector3 old_position, new_position;
new_position.R = old_position.R ± delta;
Camera.main.transform.position = Vector3.MoveTowards(new_position, old_position, speed);
in the above, R is one of the axes (x, y, or z)
i change one of the axis values at a time, and only 1 axis value at a time, in accordance to the corresponding key pressed.
this works, but the outcome is that all 3 axes’ values end up changing, not just 1 axis value, as supposed.
the primary axis reflects the predominant change, and the other 2 axes change with it, yet to a lesser degree
for instance, if i change the camera x axis value, because the key for the x axis was pressed, the camera x axis value do indeed change significantly, yet the z and y axis values change too, with it, albeit to a lesser extent
e.g. camera_position before {1, 0, 0} >> camera_position after {3, 0.5, 0.5} with a key press to move the x axis
i take it that this is due to interpolation, in turn to using something like Vector3.MoveTowards()
so i simply switched to:
new_position.R = old_position.R ± delta;
Camera.main.transform.position = new_position;
old_position = new_position;
this solves the issue and it works fine for camera position, but not camera rotation.
if i use such an approach with camera rotation, all 3 axes’ values change together, albeit the primary selected axis changes more predominantly.
can anyone tell me why do all 3 axes change together, when i manipulate a single axis alone?
thanks