- Home /
Question by
Fierce Waffle · Mar 06, 2011 at 08:09 PM ·
forceexplosion
ExplosionForce is always the same.
This is my script. The problem I am having is whether I set the rang to a million and the power too, it always seems to apply the same amount f force in the same radius.
var hitTime : int = 3; static var hitTimeStatic : int; public var hitTimeCount : int = 0; var explosionPrefab : Transform[];
function Start() { hitTimeStatic = hitTime; }
var forceRange = 50.0; var explosionPower = 100.0;
function Update () { if(hitTimeCount == hitTime) { // Applies an explosion force to all nearby rigidbodies var explosionPos : Vector3 = transform.position; var colliders : Collider[] = Physics.OverlapSphere (explosionPos, forceRange);
for (var hit : Collider in colliders) {
if (!hit)
continue;
if (hit.rigidbody)
hit.rigidbody.AddExplosionForce(explosionPower, explosionPos, forceRange, 3.0);
}
}
}
Comment