Can I ask a question?

I made a magnet effect but it works incorrectly.

There are balls in my game scene. If the distance between the magnet object and balls were less than 2.5, then magnet effects will work.

it’s my script for the magnet effect.

function Start () {

}

function Update () {
var pos : Vector3 = transform.position;

var other : GameObject = GameObject.FindWithTag(“Ball”);

  1. var dist : float;

var ran : float;

ran = Random.Range(20,25);
10.
dist = Vector3.Distance(pos,other.transform.position);

if(dist<2.5)
{
15. other.rigidbody.AddForce(Vector3(ran,0,ran),ForceMode.Force);
}

}

But, actually it doesn’t. Only one ball is affected by magnet effect.

All balls in game scene should be affected by magnet.

What’s wrong with my script?

Plz, anybody teach it to me.

Please use code tags in the future. http://forum.unity3d.com/threads/143875-Using-code-tags-properly
I believe the reason why it only affects one game object is because you are only checking one game object in Update. I think what you want is GameObject.FindGameObjectsWithTag which returns a list of the game objects with the tag.
Unity - Scripting API: GameObject.FindGameObjectsWithTag
You should store the result and run the find once in Start. In Update, you can run a for-loop to check if the object is within distance.