Exemple #1
0
 void Awake()
 {
     if (!m_cameraHolder)
     {
         m_cameraHolder = GameObject.Find("CameraHolder");
     }
     if (!m_camera)
     {
         m_camera = gameObject.GetComponent <Camera>();
         gameObject.transform.rotation = Quaternion.Euler(73f, 0f, 0f);
         m_camera.fieldOfView          = 40;
     }
     if (!m_cameraHolderBoxCollider)
     {
         if (!m_cameraHolder.GetComponent <BoxCollider>())
         {
             m_cameraHolder.AddComponent <BoxCollider>();
         }
         m_cameraHolderBoxCollider = m_cameraHolder.gameObject.GetComponent <BoxCollider>();
     }
     m_cameraHolderBoxCollider.size.Set(136f, 10f, 74f);
     if (!m_cameraHolderRigidbody)
     {
         m_cameraHolderRigidbody = m_cameraHolder.GetComponent <Rigidbody>();
     }
     m_cameraHolderRigidbody.useGravity  = false;
     m_cameraHolderRigidbody.constraints = (RigidbodyConstraints)116;//freeze y position and all rotations
     if (!m_audioHandler)
     {
         m_audioHandler = gameObject.GetComponent <AudioHandler>();
         float soundAjustment = 0.6f - ((m_camera.fieldOfView - 5) * 0.01f);
         m_audioHandler.ChangeVolumeTo(soundAjustment);
     }
 }
Exemple #2
0
 private void ApplyZoom(float zoom)
 {
     if ((zoom > 0 && m_camera.fieldOfView > m_minZoom) || (zoom < 0 && m_camera.fieldOfView < m_maxZoom))
     {
         m_camera.fieldOfView -= zoom;
         float soundAjustment = 0.6f - ((m_camera.fieldOfView - 5) * 0.01f);
         m_audioHandler.ChangeVolumeTo(soundAjustment);
         float xAdjustment = m_colliderXsizeVariationWithZoom * zoom;
         float zAdjustment = m_colliderZsizeVariationWithZoom * zoom;
         m_colliderSizeAjustment.Set(m_cameraHolderBoxCollider.size.x - xAdjustment, 10, m_cameraHolderBoxCollider.size.z - zAdjustment);
         m_cameraHolderBoxCollider.size = m_colliderSizeAjustment;
     }
 }