Beispiel #1
0
    //check if the sight line is clear
    void FixedUpdate()
    {
        if (m_IsPlayerInRange && !m_IsCaught)
        {
            //shoot ray on direction between player and observer
            Vector3    direction = m_Player.position - transform.position + Vector3.up;
            Ray        ray       = new Ray(transform.position, direction);
            RaycastHit raycastHit;

            //check if the ray hit something
            if (Physics.Raycast(ray, out raycastHit))
            {
                //check if it hits the player (not the wall)
                if (raycastHit.collider.transform == m_Player)
                {
                    m_IsCaught = true;
                    OnPlayerCaught?.Invoke(); //is there any listener
                    EndLevel(m_CaughtBackground, m_CaughtAudio);
                }
            }
        }
    }
Beispiel #2
0
 public static void NotifyPlayerCaught(PlayerController player)
 {
     OnPlayerCaught?.Invoke();
     // TODO: Replace with better caught sequence.
     SceneManager.LoadScene(SceneManager.GetActiveScene().name);
 }