private void OnTriggerStay(Collider other) { if (other.name == "Player") { UI_Manager _uiManager = GameObject.Find("Canvas").GetComponent <UI_Manager>(); Player _player = GameObject.Find("Player").GetComponent <Player>(); if (_player.playerHasCoin == false) { _uiManager.CollectCoinOverlayOn(); } else if (_player.playerHasCoin == true) { _uiManager.CollectCoinOverlayOff(); } rb.WakeUp(); if (Input.GetKeyDown(KeyCode.E)) { if (_player != null) { Debug.Log("Player Has Coin"); _player.playerHasCoin = true; AudioSource.PlayClipAtPoint(_coinPickUp, transform.position, 1f); _uiManager.CollectCoinOverlayOff(); if (_uiManager != null) { _uiManager.CollectedCoin(); } Destroy(this.gameObject, 0.5f); } } } }
// Start is called before the first frame update void Start() { Scene currentScene = SceneManager.GetActiveScene(); _charControl = GetComponent <CharacterController>(); string sceneName = currentScene.name; isFiring = false; currentAmmo = maxAmmo; UIManager = GameObject.Find("Canvas").GetComponent <UI_Manager>(); UIManager.UpdateAmmo(currentAmmo); shootingCoolDown = Time.time + 0.2f; Coin _coin = GameObject.Find("Coin").GetComponent <Coin>(); playerHasCoin = false; RemovePlayerWeapon(); UIManager.CollectCoinOverlayOff(); }
private void OnTriggerExit(Collider other) { if (other.name == "Player") { UI_Manager _uiManager = GameObject.Find("Canvas").GetComponent <UI_Manager>(); _uiManager.CollectCoinOverlayOff(); } }