// This method will initialize a collision to a standard collision that could be overriden public virtual void OnTriggerEnter(Collider other) { if (active) { GameObject.Find("Scripts").SendMessage("HealthChangeDamage", damage); // calls damage script sfxHandler.PlayAudio("barrel impact"); // calls audio script to play barrel sounds Destroy(gameObject); // removes the game object StartCoroutine("DisableScript"); // disables script for 3 seconds to avoid rapid collisions } }
// add to wallet on collision void OnTriggerEnter(Collider other) { // play pickup sound sfxHandler.PlayAudio("coin pickup"); // add amount to persistent wallet writeToWallet(); // destroy the coin Destroy(gameObject); }