| | |
| | | /// 카메라 시점 변경 속도 |
| | | /// </summary> |
| | | public float CameraRotationSpeed = 4; |
| | | ///// <summary> |
| | | ///// 마우스 휠 줌 속도 |
| | | ///// </summary> |
| | | //public float ZoomSpeewd = 5000.0f; |
| | | ///// <summary> |
| | | ///// 줌 최솟값, 작을 수록 확대할 수 있는 수치가 커짐 |
| | | ///// </summary> |
| | | //public float MinZoomValue = 10; |
| | | ///// <summary> |
| | | ///// 줌 최대값, 클 수록 축소할 수 있는 수치가 커짐 |
| | | ///// </summary> |
| | | //public float MaxZoomValue = 60; |
| | | /// <summary> |
| | | /// 마우스 휠 줌 속도 |
| | | /// </summary> |
| | | public float ZoomSpeed = 50.0f; |
| | | |
| | | public float ZoomMoveSpeed = 5f; |
| | | /// <summary> |
| | | /// 줌 최솟값, 작을 수록 확대할 수 있는 수치가 커짐 |
| | | /// </summary> |
| | | public float MinZoomValue = 10; |
| | | /// <summary> |
| | | /// 줌 최대값, 클 수록 축소할 수 있는 수치가 커짐 |
| | | /// </summary> |
| | | public float MaxZoomValue = 90; |
| | | /// <summary> |
| | | /// 카메라 이동 속도 |
| | | /// </summary> |
| | | [Range(1f, 10f)] |
| | | public float CameraMoveSpeed = 4; |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | |
| | | private ButtonControl mouseLeftButton; |
| | | |
| | | |
| | | [SerializeField] |
| | | private float m_CanMoveDistance = 3f; |
| | | //[SerializeField] |
| | | //private float m_CanMoveDistance = 3f; |
| | | |
| | | |
| | | [SerializeField] |
| | |
| | | /// </summary> |
| | | private Vector3 m_CameraInitOffset; |
| | | |
| | | private Camera m_Camera; |
| | | |
| | | private float initFieldOfView = 60.0f; |
| | | private float targetFieldOfView = 60.0f; |
| | | public override void Awake() |
| | | { |
| | | |
| | | } |
| | | void Start() |
| | | { |
| | | |
| | | m_Camera = Camera.main; |
| | | |
| | | mouseLeftButton = Mouse.current.leftButton; |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | float scrollValue = Input.GetAxis("Mouse ScrollWheel") * ZoomSpeed; |
| | | |
| | | if(scrollValue < 0 && m_Camera.fieldOfView > MinZoomValue) |
| | | { |
| | | targetFieldOfView = m_Camera.fieldOfView + scrollValue; |
| | | } |
| | | else if(scrollValue > 0 && m_Camera.fieldOfView < MaxZoomValue) |
| | | { |
| | | targetFieldOfView = m_Camera.fieldOfView + scrollValue; |
| | | } |
| | | |
| | | if(Input.GetKeyUp(KeyCode.Mouse2)) |
| | | { |
| | | targetFieldOfView = initFieldOfView; |
| | | } |
| | | |
| | | m_Camera.fieldOfView = Mathf.Lerp(m_Camera.fieldOfView, targetFieldOfView , Time.deltaTime * ZoomMoveSpeed); |
| | | } |
| | | |
| | | |
| | |
| | | mouseY = 0; |
| | | } |
| | | |
| | | //private void DistanceBasedInteriorDisplay(Vector3 vector) |
| | | //{ |
| | | // foreach (TrainInterior interior in ModelTypeManager.Inst.CurrentTrain.TrainInteriors) |
| | | // { |
| | | // float distance = Vector3.Distance(vector, interior.CentralAxis.transform.position); |
| | | |
| | | // if(distance > m_InteriorDistance) |
| | | // { |
| | | // interior.gameObject.SetActive(false); |
| | | // } else |
| | | // { |
| | | // interior.gameObject.SetActive(true); |
| | | // } |
| | | // } |
| | | //} |
| | | |
| | | |
| | | private void CameraInputMove() |
| | |
| | | return direction * CameraMoveSpeed * Time.deltaTime; |
| | | } |
| | | Vector3 movePosition = Vector3.zero; |
| | | if (Input.GetKey(InputManager.Forward)) movePosition = directionMovePos(transform.forward); |
| | | if (Input.GetKey(InputManager.Backword)) movePosition = -(directionMovePos(transform.forward)); |
| | | if (Input.GetKey(InputManager.Right)) movePosition = directionMovePos(transform.right); |
| | | if (Input.GetKey(InputManager.Left)) movePosition = -(directionMovePos(transform.right)); |
| | | if (Input.GetKey(InputManager.Up)) movePosition = directionMovePos(transform.up); |
| | | if (Input.GetKey(InputManager.Down)) movePosition = -(directionMovePos(transform.up)); |
| | | if (Input.GetKey(InputManager.Forward)) movePosition += directionMovePos(transform.forward); |
| | | if (Input.GetKey(InputManager.Backword)) movePosition -= directionMovePos(transform.forward); |
| | | if (Input.GetKey(InputManager.Right)) movePosition += directionMovePos(transform.right); |
| | | if (Input.GetKey(InputManager.Left)) movePosition -= directionMovePos(transform.right); |
| | | if (Input.GetKey(InputManager.Up)) movePosition += directionMovePos(transform.up); |
| | | if (Input.GetKey(InputManager.Down)) movePosition -= directionMovePos(transform.up); |
| | | |
| | | transform.position += movePosition; |
| | | |
| | | if(transform.position.y < 0) |
| | | { |
| | | movePosition =new Vector3(transform.position.x, 0, transform.position.z); |
| | | transform.position = movePosition; |
| | | } |
| | | |
| | | |
| | | if (transform.position.x > m_CameraInitOffset.x + m_CanMoveDistance) |
| | | { |
| | | transform.position = new Vector3(transform.position.x - movePosition.x, transform.position.y, transform.position.z); |
| | | } |
| | | else if (transform.position.x < m_CameraInitOffset.x - m_CanMoveDistance) |
| | | { |
| | | transform.position = new Vector3(transform.position.x - movePosition.x, transform.position.y, transform.position.z); |
| | | } |
| | | |
| | | if (transform.position.y > m_CameraInitOffset.y + m_CanMoveDistance) |
| | | { |
| | | transform.position = new Vector3(transform.position.x, transform.position.y - movePosition.y, transform.position.z); |
| | | } |
| | | else if (transform.position.y < m_CameraInitOffset.y - m_CanMoveDistance) |
| | | { |
| | | transform.position = new Vector3(transform.position.x, transform.position.y - movePosition.y, transform.position.z); |
| | | } |
| | | |
| | | if (transform.position.z > m_CameraInitOffset.z + m_CanMoveDistance) |
| | | { |
| | | transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z - movePosition.z); |
| | | } |
| | | else if (transform.position.z < m_CameraInitOffset.z - m_CanMoveDistance) |
| | | { |
| | | transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z - movePosition.z); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |