spell hit rigidbody

i made this spell casting script and i want it to hit other rigidbodys how do i do that
here is the scrip

var spell : Transform;

function Update () 
{
  if(Input.GetButtonDown("Fire2"))
  {
    var magic = Instantiate(spell, GameObject.Find("spawnPoint").transform.position, 
    Quaternion.identity);
    magic.rigidbody.AddForce(transform.forward * 2000);
  }
}

here is the script on the fireball

var ParticlePrefab : GameObject;
function OnCollisionEnter(collision : Collision)
{
     : Instantiate(transform.position, transform.rotation, ...);
	 Instantiate(ParticlePrefab, transform.position, transform.rotation);
     Destroy(gameObject);
}

Ok, I think I noticed a few problems in your scripts.

  1. Instantiating a transform makes an empty GameObject. You do this in your firing script. I’m pretty sure thats not what you want to do. Instantiate a GameObject Instead like so: var spell : GameObject; and then later var magic = Instantiate(spell, spawner.position, spawner.rotation);.
  2. You use GameObject.Find, without assigning it. Its much more efficient (in CPU cycles), to have var spawner : Transform;, instead of “GameObject.Find(“spawnPoint”)”. Even if you ever have to find a GameObject, its preferable to use GameObject.FindWithTag.
  3. You use Quaternion.Identity instead of the rotation of the spawner. This makes it always look forward, even if say, whatever is using the spell, is facing sideways.
  4. I see “: Instantiate(transform.position, transform.rotation, ...);” I hope thats not your real script, because that will most certainly not work.

I think those are bugs that are in your script. I may have missed some, unfortunately, as there are many. I do hope you get your script working right.

Good Luck!