Ejemplo n.º 1
0
        /// <summary>
        /// Returns the point that the canera is looking at.
        /// </summary>
        /// <returns>The point that the camera is looking at.</returns>
        public Vector3 SharedMethod_TargetLookPosition()
        {
            // The SharedMethod may be called before Start is called.
            if (m_ViewMode == null)
            {
                SharedManager.InitializeSharedFields(Utility.FindCamera(gameObject).gameObject, this);
            }

            return(CameraMonitor.TargetLookPosition(m_CameraTargetLookRay, m_CameraTargetLock, m_CameraLookDistance, m_ViewMode.Get()));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Cache the component references and initialize the default values.
        /// </summary>
        private void Awake()
        {
            m_Transform     = transform;
            m_Camera        = GetComponent <Camera>();
            m_CameraHandler = GetComponent <CameraHandler>();
            m_CameraMonitor = GetComponent <CameraMonitor>();

            SharedManager.Register(this);

            m_StartPitch = m_Pitch = m_Transform.eulerAngles.x;

            // The active state is a unique state which is layered by the additional states.
            m_ActiveState = ScriptableObject.CreateInstance <CameraState>();
            if (m_CameraStates == null || m_CameraStates.Length == 0)
            {
                m_DefaultState = ScriptableObject.CreateInstance <CameraState>();
                m_CameraStates = new CameraState[] { m_DefaultState };
            }
            else
            {
                m_DefaultState = m_CameraStates[0];
            }
            for (int i = 0; i < m_CameraStates.Length; ++i)
            {
                m_CameraStatesMap.Add(m_CameraStates[i].name, m_CameraStates[i]);
            }
            ChangeState(m_DefaultState, true);

            // If the character is not initialized on start then disable the controller - the controller won't function without a character.
            if (m_InitCharacterOnStart)
            {
                if (m_Character == null)
                {
                    Debug.LogWarning("Warning: No character has been assigned to the Camera Controller. It will automatically be assigned to the GameObject with the Player tag.");
                    m_Character = GameObject.FindGameObjectWithTag("Player");
                    if (m_Character == null)
                    {
                        Debug.LogWarning("Error: Unable to find character with the Player tag. Disabling the Camera Controller.");
                        m_CameraHandler.enabled = enabled = false;
                        return;
                    }
                }
                InitializeCharacter(m_Character);
            }
            else
            {
                m_CameraHandler.enabled = enabled = m_Character != null;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Returns the direction that the camera is looking. An example of where this is used include when the GUI needs to determine if the crosshairs is looking at any enemies.
 /// </summary>
 /// <param name="applyRecoil">Should the target ray take into account any recoil?</param>
 /// <returns>A ray in the direction that the camera is looking.</returns>
 private Vector3 SharedMethod_TargetLookDirection(bool applyRecoil)
 {
     return(CameraMonitor.TargetLookDirection(m_CameraTargetLookRay, m_CameraTargetLock, applyRecoil ? m_CameraRecoil : 0));
 }