/// <summary> /// Use WASD tp change the position, rotation, fov of camera /// </summary> private void UpdateCameraPosition() { //if (ChangingCameraPosition) //{ if (CurrentCamera != null) { if (IsChangingFOV) //Control fov { CurrentCamera.GetComponent <UnityEngine.Camera>().fieldOfView += Input.InputControl.GetAxis(Input.Controls.Global.GetAxes().cameraLateral); //Limit fov to range from 0 to 180 float fov = CurrentCamera.GetComponent <UnityEngine.Camera>().fieldOfView; if (fov > 179) { fov = 179; //Not quite 180 because at 180 it has this weird circle thing } else if (fov < 0) { fov = 0; } CurrentCamera.GetComponent <UnityEngine.Camera>().fieldOfView = fov; } else if (IsShowingAngle) //Control rotation (only when the angle panel is active) { CurrentCamera.transform.Rotate(new Vector3(-Input.InputControl.GetAxis(Input.Controls.Global.GetAxes().cameraLateral) * rotationSpeed, Input.InputControl.GetAxis(Input.Controls.Global.GetAxes().cameraForward) * rotationSpeed, 0) * Time.deltaTime); } CurrentCamera.GetComponent <RobotCamera>().UpdateConfiguration(); } //} }
private void ChangeCamera(GameObject activeCamera, string cameraType, int cameraIndex) { if (CurrentCamera != null) { CurrentCamera.GetComponent <Camera>().enabled = false; } activeCamera.GetComponent <Camera>().enabled = true; CurrentCamera = activeCamera; CurrentCameraType = cameraType; CurrentCameraIndex = cameraIndex; }
/// <summary> /// Use WASD change the position, rotation of camera /// </summary> private void UpdateCameraPosition() { if (ChangingCameraPosition) { if (IsChangingFOV) { CurrentCamera.GetComponent <Camera>().fieldOfView += Input.GetAxis("CameraVertical"); } else if (IsShowingAngle) //Control rotation (only when the angle panel is active) { CurrentCamera.transform.Rotate(new Vector3(-Input.GetAxis("CameraVertical") * rotationSpeed, Input.GetAxis("CameraHorizontal") * rotationSpeed, 0) * Time.deltaTime); } else if (!IsChangingHeight) //Control horizontal plane transform { CurrentCamera.transform.Translate(new Vector3(Input.GetAxis("CameraHorizontal") * positionSpeed, 0, Input.GetAxis("CameraVertical") * positionSpeed) * Time.deltaTime); } else //Control height transform { CurrentCamera.transform.Translate(new Vector3(0, Input.GetAxis("CameraVertical") * positionSpeed, 0) * Time.deltaTime); } } }