Problem with Enemy AI

This question will probably solve itself as i search through out the internet but ill give it another shot.

So this time, my problem revolves around a Entity that i want to make in my game. This Entity, the Enemy, has basically basic functions on following the target but a bit lacking on its shooting part. It basically is going to follow its target until it goes close enough to it so it shoots. Half the part is done, with the enemy stalking the player until its in range. The problem i am having right now is that when it shoots it does the following:

  1. It doesn’t shoot straight.
  2. Its fire-rate is really high. Even with the limitation on the script. (I probably have screwed something up)

(Here is what i deal with… Screen capture - 0ff257d8260c74340fbbce6919188244 - Gyazo)

I am not really sure how to solve this considering i am relatively new to scripting in C# but i would like to have some insight on this.

C# Code :
using UnityEngine;
using System.Collections;

public class EnemyAI : MonoBehaviour {

public float playerTargetDistance;
public float shootingRange;
public float lifetime = 5f;
public float speed = 20f;
public float baseSpeed = 20f;
public Transform playerTarget;
public Rigidbody EnemyBullet;
public Transform EnemyChamber;
public float shotTime;
public float intervalShots = 1.7f;

// Use this for initialization
void Start () {
}

// Update is called once per frame
void Update () {
	if (shotTime > 0) {
		shotTime -= Time.deltaTime;
	}

	if(Vector3.Distance(transform.position, playerTarget.position) <= playerTargetDistance){
		transform.position = Vector3.MoveTowards(transform.position, playerTarget.position, speed);
		transform.LookAt(playerTarget);
		if(Vector3.Distance(transform.position, playerTarget.position) <= shootingRange){
			speed = 0;
            Shoot();
		}
		else
		{
			speed = baseSpeed;
		}
	}
}

void Shoot() {

	Rigidbody EnemyShot;
	EnemyShot = Instantiate (EnemyBullet, EnemyChamber.position, EnemyChamber.rotation) as Rigidbody;
	EnemyShot.AddForce (EnemyChamber.forward * 5000f);
	Destroy (EnemyShot.gameObject,lifetime);
}

}

P.S: I might find the solution on the internet but at this rate, i wont have any luck finding the right post for it. So any helpful sites will help me a hole lot! :smiley:

Try this script it works for me but it doesnt shoot but only follow
using UnityEngine;
using System.Collections;

public class EnemyAI : MonoBehaviour {
Transform tr_Player;
float f_RotSpeed=3.0f,f_MoveSpeed = 3.0f;

// Use this for initialization
void Start () {
	
	tr_Player = GameObject.FindGameObjectWithTag ("Player").transform; }

// Update is called once per frame
void Update () {
	/* Look at Player*/
	transform.rotation = Quaternion.Slerp (transform.rotation , Quaternion.LookRotation (tr_Player.position - transform.position) , f_RotSpeed * Time.deltaTime);
	
	/* Move at Player*/
	transform.position += transform.forward * f_MoveSpeed * Time.deltaTime;
}

}