How do i make my player just shoot every other second

Guys i have a enemy that can now shoot but its contant, i have checked the time.time function but how would i go about implementing it in my code so that it shoots once a second for instance can someone point me in the right direction as this link is fine but it still doesnt make me understand how to implement this when the enemy is shooting it just shows me when a button is pressed, i realise as the bullet is in the update function its constantly updating the bullet

this is my code below

	public Rigidbody bullet;  // bullet object
	public float damp = 1.0f;
	public float bulletLife = 2.0f;
	
			
  
	
	
	

	

	// Update is called once per frame
	void Update () 
	{	
			if(LookAtTarget)
		{
			var Rotate = Quaternion.LookRotation(LookAtTarget.position - transform.position);	
			transform.rotation = Quaternion.Slerp(transform.rotation, Rotate, Time.deltaTime * damp);
			
			
			{
				ShootPlayer();
			}
			
		}
		
			
	}
		
	void ShootPlayer()
	{
		
			
		Rigidbody newBullet = Instantiate(bullet, transform.Find("spawnpoint").transform.position, Quaternion.identity)as Rigidbody;	
		newBullet.AddForce(transform.forward * 1000);  // add the force to shoot the bullet forward
		Destroy(newBullet.gameObject, bulletLife);  // remove the bullet from the scene when it has shot 
	}
	

}

:wink:

you have no code at all for a timer, so have you even tried?

AllowedToShoot = true;
    IEnumerator ShootPlayer()

    {

if (AllowedToShoot){
AllowedToShoot = false;
        Rigidbody newBullet = Instantiate(bullet, transform.Find("spawnpoint").transform.position, Quaternion.identity)as Rigidbody;    

        newBullet.AddForce(transform.forward * 1000);  // add the force to shoot the bullet forward

        Destroy(newBullet.gameObject, bulletLife);  // remove the bullet from the scene when it has shot 
yield return new WaitForSeconds(1f);
AllowedToShoot = true;
}
    }

and change
ShootPlayer();
to
StartCoroutine( ShootPlayer() );

Its a start and could work, or you could implement a check using time in the update function :wink:

Also i would cache the FindObject like so

Vector3 shootPosition;

void Start(){
shootPosition = transform.Find("spawnpoint").transform.position
}

Instead of a coroutine i would suggest

float LastShot
float TimeBetweenShots = 1.0

update
if(Time.time > LastShot + TmeBetweenShots)
  LastShot = Time.time
  Shoot()

no i didnt try any of this elite but thanks this has worked a treat i am just trying to understand the code and let me know if i have got this right or not:

AllowedToShoot = true; the boolean value

after reading up about coroutines and IEnumerator ShootPlayer() its kind of like a function that continuely executes a specific set of instrcutions in my case the ShootPlayer function below and then circles through the loop of code continuesly, if i am wrong i apologise.