private void OnTriggerEnter(Collider other) { //handles collectible count, then special collectible attribute, then the object deactivates if (other.gameObject.tag == "Player" && tag == "CollectableCollider") { if (transform.parent.tag == "normieCollectible") { //normie special TBD hd.handleHealth(5, false); gm.handleColCount(); } else if (transform.parent.tag == "healCollectible") { hd.handleHealth(3, true); gm.handleColCount(); } else if (transform.parent.tag == "scoreCollectible") { gm.handleGoldColCount(); } SoundManager.PlaySFX(gaspClip, true, .6f); Transform clone = Instantiate(collectPfx.transform, transform.position, Quaternion.identity); clone.transform.rotation = Quaternion.Euler(new Vector3(-90, transform.rotation.y, 0)); collectPfx.SetActive(true); //clone gameobject is destroyed after .75s Destroy(clone.gameObject, 0.75f); transform.parent.gameObject.SetActive(false); } }
//COLLISION CHECKS //checks collision entering private void OnCollisionEnter(Collision collision) { //checks the impact force impactForce = collision.impulse.magnitude; if (collision.gameObject.tag == "Hazard" || collision.gameObject.tag == "Deathball") { isDead = true; gm.touchHazard = true; SoundManager.PlaySFX(deathClip, true, 1f); //enable ragdoll physics EnableRagdoll(); } if (impactForce > 12f && isGrounded) { SoundManager.PlaySFX(footstepClip, true, .4f); } if (isAnchored && !isGrounded) { if (!headCheck && impactForce > maxImpact * .6f && grapple.curRopeLength > grapple.maxRopeRange * .5f) { SoundManager.PlaySFX(impactClip, true, Mathf.Clamp01(impactForce / maxImpact)); SoundManager.PlaySFX(deathClip, true, 1f); pHealth.handleHealth(-(int)impactForce / 3, false);//small dmg } } else { if (impactForce > maxImpact * .5f)//handle impact dmg/sfx { SoundManager.PlaySFX(impactClip, true, Mathf.Clamp01(impactForce / maxImpact)); SoundManager.PlaySFX(deathClip, true, 1f); pHealth.handleHealth(-(int)impactForce / 3, false); //small dmg } else if (impactForce > maxImpact * .85f && !isAnchored) //if close to max impact -2 chunks { SoundManager.PlaySFX(deathClip, true, 1f); pHealth.handleHealth(-2, true); } if (impactForce > maxImpact) { SoundManager.PlaySFX(deathClip, true, 1f); isDead = true; EnableRagdoll(); } } }