Hi All,
Wonder if someone can have a look at my script and tell me if they can see a problem.
I want to create a black hole effect around a sprite. The player has a rigidbody and mesh collider attached and the black hole has a sphere collider (trigger) attached and then this script.
#pragma strict
var radius = 5.0;
var power = -10.0;
function Update () {
// Applies an explosion force to all nearby rigidbodies
var explosionPos : Vector3 = transform.position;
var colliders : Collider[] = Physics.OverlapSphere (explosionPos, radius);
for (var hit : Collider in colliders) {
if (!hit)
continue;
if (hit.rigidbody)
hit.rigidbody.AddExplosionForce(power, explosionPos, radius, 3.0);
}
}
Thanks in advance for any pointers.