private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("Water")) { WaterController water = collision.gameObject.GetComponent <WaterController>(); if (water) { if (water.electrified) { audioS.clip = shock; audioS.Play(); Vector2 knockbackDirection = Vector2.up * electricWaterKnockback; rb.AddForce(knockbackDirection * knockback, ForceMode2D.Impulse); staticParticles1.Play(); staticParticles2.Play(); TakeDamage(1); return; } } } else if (state == playerState.Diving) { ContactPoint2D[] contacts = collision.contacts; MovingEntity enemy = collision.gameObject.GetComponent <MovingEntity>(); if (enemy) { Vector2 knockbackDirection = Vector2.Reflect(-collision.relativeVelocity, contacts[0].normal); rb.AddForce(knockbackDirection * knockback * enemy.knockbackMultiplier, ForceMode2D.Impulse); enemy.divedOnto(collision); } } }