Auto shooting script.

Hello. I have a touchgame that i am working on, and its a platformer game. I have 2 cubes that are going to shoot at eachother automaticly, without the use of aiming etc.

Does anyone have some kind of script to make this work? Thanks

var projectile : Rigidbody;//HERE DRAG A BULLED WITH RIGIDBODY IN INSPECTER
var speed = 20;
var rate : float = 0.5;
private var rate_time : float;

function Update()
{
   
      rate_time = Time.time + rate;
      var instantiatedProjectile : Rigidbody = Instantiate(projectile, transform.position, transform.rotation );
      instantiatedProjectile.velocity = transform.TransformDirection( Vector3( 0, 0, speed ) );
      Physics.IgnoreCollision( instantiatedProjectile. collider, transform.root.collider );
  
}