Hello,
I’m new to Unity and I already ran into my first challenge (Probably due to my weak Math background).
I’m trying to move the camera the same way the camera is moved under Unity when your are viewing the scene from the right side and the camera is rotated (e.g. 20 degrees).
In other words, when I move the camera back and forth along the Z-axis I also want to affect the Y position, in a proportional way.
In other words, a third person camera zoom(camera gets closer or further) in/out functionality.
I have managed to do it and it works except that I feel that is not done “the right way”.
This is the way I’m doing it currently:
float dx = (inputVector.x * cameraSpeed) * Time.deltaTime;
float dy = (inputVector.z * (cameraSpeed * -0.5f)) * Time.deltaTime;
float dz = (inputVector.z * cameraSpeed) * Time.deltaTime;
float x = currentCameraPosition.x + dx;
float y = currentCameraPosition.y + dy;
float z = currentCameraPosition.z + dz;
gameCamera.transform.position = new Vector3(x, y, z);
Also, where is the base of the vector representing the camera position? The origin?
Any input would be appreciated it. Thanks in advance.