I’ve been working on adding a trigger that causes an ai to emit an explosive force. I have a sphere collider with the trigger button selected and this script but it dosen’t work.
var radius = 5.0;
var power = 10.0;
function OnTriggerEnter (other : Collider) {
// 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 && other.tag == "target")
hit.rigidbody.AddExplosionForce(power, explosionPos, radius, 3.0);
}
}