Advertisement
Guest User

Untitled

a guest
Sep 9th, 2017
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
BOO 0.88 KB | None | 0 0
  1. import UnityEngine
  2.  
  3. [AddComponentMenu("Interface/Centre Ship Camera")]
  4.  
  5. class CentreShipCamera(MonoBehaviour):
  6.    
  7.     [SerializeField] m_target as Transform
  8.     [SerializeField] m_zoomAxis = "Mouse ScrollWheel"
  9.     [SerializeField] m_zoomSpeed = 1f
  10.     [SerializeField] m_minZoom = 4f
  11.     [SerializeField] m_maxZoom = 100f
  12.    
  13.     m_offset as Vector3
  14.     m_normalizedOffset as Vector3
  15.     m_fieldOfView as single
  16.    
  17.     def Start():
  18.         m_offset = transform.position - m_target.position
  19.         m_normalizedOffset = m_offset.normalized
  20.         m_fieldOfView = (camera.orthographicSize if camera.isOrthoGraphic else camera.fieldOfView)
  21.    
  22.     def LateUpdate():
  23.         m_fieldOfView *= 1f - Input.GetAxis(m_zoomAxis)*m_zoomSpeed
  24.         m_fieldOfView = Mathf.Clamp(m_fieldOfView, m_minZoom, m_maxZoom)
  25.         camera.orthographicSize = m_fieldOfView;
  26.         camera.fieldOfView = m_fieldOfView
  27.         transform.position = m_target.position + m_offset
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement