Here, I just implemented it myself... Tho it's still far from perfect, it simulates the behavior I need for this moment.
Just create a `RigidbodyExtensions.cs` anywhere inside the unity project and add this:
using UnityEngine;
using System.Collections;
public static class RigidbodyExtensions : object {
public static void AddExplosionForce (this Rigidbody body, float explosionForce, Vector3 explosionRadiusCenter, float explosionRadius) {
AddExplosionForce(body, explosionForce, explosionRadiusCenter, explosionRadius, new Vector3(0F, 0F, 0F));
}
public static void AddExplosionForce (this Rigidbody body, float explosionForce, Vector3 explosionRadiusCenter, float explosionRadius, Vector3 explosionOriginPoint) {
AddExplosionForce(body, explosionForce, explosionRadiusCenter, explosionRadius, explosionOriginPoint, ForceMode.Force);
}
public static void AddExplosionForce ( // still missing torque - try using "AddForceAtPosition" later on
this Rigidbody body
, float explosionForce
, Vector3 explosionRadiusCenter
, float explosionRadius
, Vector3 explosionOriginPoint // this is the oposite from upwardsModifier
, ForceMode mode
) {
if (Vector3.Distance(body.transform.position, explosionRadiusCenter) <= explosionRadius) {
Vector3 force = (body.transform.position - (explosionRadiusCenter + explosionOriginPoint));
body.AddForce(force * (explosionForce/5), mode); // 5 came from experimentation
}
}
}
here's a comparison usage:
rigidbody.AddExplosionForce(2000F, transform.position, 2F, 3f); // unity's
rigidbody.AddExplosionForce(2000F, transform.position, 2F, -(new Vector3(0F, 3F, 0F))); // cawas
note the `**-**` sign. it's needed for similar behavior.