Пример #1
0
    void OnTriggerEnter(Collider other)
    {
        //only accept collision if active
        if (m_isActive)
        {
            //check if it's player
            if (other.CompareTag("Player"))
            {
                //set inactive
                m_isActive = false;
                //play audio
                m_audio.Play();
                //check type
                switch (m_type)
                {
                case 1:                 //health type
                    m_player.AddHealth();
                    break;

                case 2:                 //ammo type
                    m_player.AddAmmo();
                    break;

                default:
                    Debug.Log("Pick up not set!");
                    break;
                }
                //start coroutine to recharge
                StartCoroutine("Recharge");
            }
        }
    }