public void OnCollisionEnter(Collision collision) { if (collision.collider.CompareTag("Cube")) { Composite comp = collision.collider.GetComponentInParent <Composite>(); //check if HP > 0, this so if the cube has only one HP, but touches //multiple bricks at once, only one will be destroyed if (comp.HP > 0) { //shake the cam, for the fans destroyCamShakeSettings.Shake(); if (!Invincible) { gameObject.SetActive(false); if (!hasDied) { hasDied = true; GetComponent <MeshRenderer>().material = waterMaterial; } } comp.HP--; OnCubeEnter.Invoke(comp); } } }
IEnumerator PlayEffect() { //shake cam destroyCamShakeSettings.Shake(); //ease in trgt = TargetTemp; yield return(new WaitUntil(() => FloatEq(postProcessing.colorGrading.settings.basic.temperature, trgt))); //hold yield return(new WaitForSeconds(HoldDuration)); //fade out trgt = 0.0f; yield return(new WaitUntil(() => FloatEq(postProcessing.colorGrading.settings.basic.temperature, trgt))); Destroy(gameObject); }