void OnTriggerEnter2D(Collider2D other) { if (1 << other.gameObject.layer == obstacleLayerMask.value) { StackPool pool = poolDictionary[other.gameObject.tag]; other.gameObject.SetActive(false); pool.Push(other.gameObject); } }
private void OnCollisionEnter(Collision collision) { splash.Play(); splash.transform.SetParent(null); if (collision.collider.gameObject.layer == 9) { collision.collider.GetComponent <Health>().DealDamage(damage); Instantiate(splashAudioPrefab, this.transform.position, Quaternion.identity); } stackPool.Push(gameObject); }
IEnumerator ExpireCoroutine() { yield return(new WaitForSeconds(expiryTime)); if (pool) { pool.Push(gameObject); if (gameObject.GetComponent <CoffeeProjectile>()) { gameObject.GetComponent <BoxCollider>().enabled = false; } } else { Destroy(gameObject); } }