public void OnTriggerEnter(Collider other) { // Check if triggered by player if (other.gameObject.layer == 10) { Status status = other.gameObject.GetComponent <Status>(); switch (data.StatType()) { case CollectibleData.Type.Health: status.AddHealth(data.Value()); break; } pickupSound.Play(); Collected(); } }