private void OnCollisionEnter(Collision collision) { if (pointsEarned) //metal { if (collision.gameObject.tag == "Surface") { ImpactFloor(); } else { Obstacle o = collision.gameObject.GetComponent <Obstacle>(); if (o != null) { if (o.DisableObstacle()) { ObstacleSpawner.DisableForSeconds(o, 5f); } } else { FallingObject c = collision.gameObject.GetComponent <FallingObject>(); if (c != null) { c.SuccessfullyClick(); } } } } else //wooden thing { if (collision.gameObject.tag == "Surface" || collision.gameObject.tag == "Obstacle") { ImpactFloor(); } else { Block b = collision.gameObject.GetComponent <Block>(); if (b != null) { if (b.isGrounded) { ImpactFloor(); } else { if (audioMod != null) { audioMod.PlayAudioClip(2); } } } } } }
private void OnTriggerEnter(Collider other) { if (pointsEarned) //metal { if (other.gameObject.tag == "Surface") { if (pointsEarned && landFX != null) { Instantiate(landFX, other.ClosestPointOnBounds(transform.position), Quaternion.identity, null); landFX = null; dragFX.SetActive(true); } foreach (Collider c in GetComponentsInChildren <Collider>()) { c.isTrigger = false; } ImpactFloor(); } else if (other.gameObject.tag == "Obstacle") { Obstacle o = other.gameObject.GetComponent <Obstacle>(); if (o != null) { if (o.DisableObstacle()) { if (audioMod != null) { audioMod.PlayAudioClip(4); } ObstacleSpawner.DisableForSeconds(o, 5f); } } } else { FallingObject c = other.GetComponent <FallingObject>(); if (c != null) { c.SuccessfullyClick(); } } } }