private void takeDamage(BaseProjectile projectile, int damage) { var playerPosition = player.getPlayerPosition(); var pushbackFactor = projectile.getPushbackFactor(); var enemyPosition = transform.position; var distanceVector = playerPosition - enemyPosition; var distanceVectorNormalized = distanceVector.normalized; var resultVector = distanceVectorNormalized * pushbackFactor; myRigidbody.AddForce(-resultVector, ForceMode.Force); var percent = 100f / (projectile.getMaxStoppingFactor() / projectile.getStoppingFactor()); slowDown(percent); updateHealth(damage); }