Enemy needs to shoot precisely at player

I'm using the FPS Tutorial and now i have a problem with it. The enemy didn't shoot precisely. One of the 10 bullet hits me, also if i stand at one place, it can't hit me. Is there someone can help this and tell me how to fix it. Because the mention of the enemy is that he is killing you, but if one of his bullets is hit me, it has no function.

Please help, IT'S A SERIOUS PROBLEM...

I just took a look at the tutorial you are talking about.

In this project, on the Robot prefab, there is a script called AI.js;

The problem lies between two things

`var shoot angle = 4.0`

This poses an issue. With this too small, it will shoot less often, and be much less likely to hit you if you are moving. It won't "lead" a shot.

With this too large, if it doesn't continue to turn, you will be satisfied without actually being pointed at the target.

The other thing is really the heart of the issue. If you notice, he always shoots just to your left. His rockets shoot from his right.

The rotation it is being satisfied from is his gameObject.transform to yours, when instead it needs to be from his child (rocket launcher).transform to yours. This is why it thinks it is aiming at you when it isn't.

I do not know the FPS Tutorial, but you could use this script. Assign the tag "Player" to your player object and attach this script to your bullet prefab. (The smooth value defines the duration of the "flight".)

var target : Transform;
var smooth : float = 5.0; 

function Start () {
  target = GameObject.FindWithTag("Player").transform;

function Update () {
  transform.position = Vector3.Lerp (transform.position, target.position,Time.deltaTime * smooth);