void HitEnemy(Collision collision) { direction = collision.transform.position - transform.position; direction.Normalize(); RNG_multiplier = UnityEngine.Random.Range(ballConfig.RNGMinMultiplier, ballConfig.RNGMaxMultiplier); float RPM = Mathf.Clamp(ballDur.RPM, 0, ballConfig.maxRPM); //Magnitude formula magnitude = (rb.velocity.magnitude * ballConfig.velocityMultiplier + 1200 * ballConfig.RPMMultiplier) * RNG_multiplier; if (doCrit) { if (superCritEnabled) { magnitude *= ballConfig.superCritMultiplier; } else { magnitude *= critMultiplier; } if (critSparks != null) { critSparks.Play(); } audioSource.clip = audioCrit; audioSource.pitch = 1.0f; } else { if (sparks != null) { sparks.Play(); } audioSource.clip = audioHit; audioSource.pitch = UnityEngine.Random.Range(0.5f, 2.0f); } if (audioSource != null) { audioSource.Play(); } if (magnitude > debugForceLimit) { /* * Debug.Log("<b>Excessive force</b> (" + (int)magnitude + ")" + Environment.NewLine + "<b>Crit:</b> " + doCrit + " <b>RPM push force:</b> " + (int)(ballRPM.RPM * ballConfig.RPMMultiplier) + " <b>Velocity push force:</b> " + (int)(rb.velocity.magnitude * ballConfig.velocityMultiplier)); + + //*/ } if (ballPhysics != null) { ballPhysics.NewCircular(); } finalForce = direction * magnitude; collision.rigidbody.AddForce(finalForce); if (gameObject.layer != 13) //layer 13 "Invulnerable", used for !grow { ballDur.RPM -= UnityEngine.Random.Range(ballConfig.DurMinDamageOnHit, ballConfig.DurMaxDamageOnHit); } }