Shooting with relode

ok so here is my question, ive created a new post because it has more depth to it, heres my old post: http://forum.unity3d.com/viewtopic.php?p=386763#386763

ok so I want to make it so when you push the left mouse button it shoots (i have the shoot script) you cant shoot again for another 3 seconds :slight_smile: please help

You could add a simple Timer in your shooting function.

private var reloadTime : float = Mathf.Infinity;

private function shoot()
{
if(Time.time < reloadTime)
{
//SHOOT!
reloadTime = Time.time +3.0;
}
}

//Edit:
Small mistake in the first script- now it should work.

so here is my code, i cant get it to fit propaly

//moving around
var speed = 3.0;
var rotateSpeed = 3.0;
//shooting
var bulletPrefab:Transform;

//dying
static var dead = false;

function LateUpdate()
{
	if(dead)
	{
		transform.position = Vector3(11.43052,0.5782776,18.09122);
		gameObject.Find ("Camera").transform.position = Vector3(0,4,-10);
		dead = false;
	}
	
}

//function OnControllerColliderHit(hit: ControllerColliderHit)
function OnTriggerEnter( hit : Collider)
{
	if(hit.gameObject.tag == "fallout")
	{
		dead = true;
		HealthControl.LIVES -= 1;
	}
	
	if(hit.gameObject.tag == "HeroBullit")
	{
		gotHit = true;
		HealthControl.HITS += 1;
		Destroy(hit.gameObject);
	}

}

function Update ()
        {
            var controller : CharacterController = GetComponent(CharacterController);
            transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
            var forward = transform.TransformDirection(Vector3.forward);
            var curSpeed = speed * Input.GetAxis ("Vertical");
            controller.SimpleMove(forward * curSpeed);
   
if(Input.GetMouseButton(0)){ 
     {
          var bullit = Instantiate(bulletPrefab, transform.Find("SpawnPoint").transform.position, Quaternion.identity);
          bullit.tag = "wormProgectile";
          bullit.rigidbody.AddForce(transform.forward * 3000);
     }
     
 }

@script RequireComponent(CharacterController)
if(Input.GetMouseButton(0))
{

if(Time.time < reloadTime)
{

          var bullit = Instantiate(bulletPrefab, transform.Find("SpawnPoint").transform.position, Quaternion.identity);
          bullit.tag = "wormProgectile";
          bullit.rigidbody.AddForce(transform.forward * 3000);
reloadTime = Time.time +3.0;
}

}

Don´t forget to initialize reloadTime with Infinity.