private void OnCollisionEnter(Collision collision) { // Destroy particles the player touches so they don't affect the player's physics (a piece of bush can no longer fling the player in the air) if (collision.collider.gameObject.CompareTag("PolyParticle")) { Destroy(collision.collider.gameObject); } // Collect any item the player touches if (collision.collider.gameObject.CompareTag("Item")) { ItemScript item = collision.collider.gameObject.GetComponent <ItemScript>(); item.Collect(); // Handle item-specific effects switch (item.itemType) { case ItemScript.Type.HealthBoost: healthManager.health = maxHealth; StaticSaverScript.health = maxHealth; ShowMessage("[ITEM ACQUIRED]\n\nHealth restored!", 2.0f); break; case ItemScript.Type.HealthMaxBoost: maxHealth++; healthManager.health = maxHealth; StaticSaverScript.maxHealth = maxHealth; ShowMessage("[ITEM ACQUIRED]\n\nMaximum health increased!", 2.8f); break; case ItemScript.Type.RockbreakerSword: SwordScript sword = swordHitbox.GetComponent <SwordScript>(); sword.power++; sword.knockbackForce += 100.0f; StaticSaverScript.swordPower = sword.power; StaticSaverScript.swordKnockback = sword.knockbackForce; ShowMessage("[ITEM ACQUIRED]\n\nRockbreaker Sword!\n\nMore powerful, and can break weak rocks.", 4.5f); break; case ItemScript.Type.Torch: Transform torch = collision.collider.gameObject.transform.GetChild(0); // Just steal the torch's point light torch.SetParent(transform); torch.localPosition = new Vector3(0.0f, 0.25f, 0.0f); ShowMessage("[ITEM ACQUIRED]\n\nTorch!\n\nSee in the dark.", 2.5f); break; } } }