var projectile : Rigidbody;
var speed = 20;
var reloadTime = 0.01;
var ammoCount = 20;
var clipSize = 20;
var reloadSpeed = 0.01;
private var lastShot = -10.0;

var audi : AudioClip;
function Update()
{
	if(networkView.isMine)
	{
if( Input.GetButton( "Fire1" ) )
	{
		if (Time.time > reloadTime + lastShot && ammoCount > 0)
		{
		
		var instantiatedProjectile : Rigidbody = Network.Instantiate(projectile, transform.position, transform.rotation,0);  //Instantiate(projectile, transform.position, transform.rotation );
		instantiatedProjectile.velocity = transform.TransformDirection( Vector3( 0, 0, speed ) );
		//Physics.IgnoreCollision( instantiatedProjectile. collider,transform.root.collider );
		AudioSource.PlayClipAtPoint(audi, transform.position);
		lastShot = Time.time;
		ammoCount--;
		}
		}
		}

	
if( 0 == ammoCount && Input.GetKeyUp("r") )
{
		Reload();	
}

}

function Reload()
{
	yield WaitForSeconds(reloadTime + reloadSpeed);
	ammoCount = clipSize;
}