gettin an error with enemy shooting a bullet

Hi Guys,

I am trying to get the enemy to shoot at the player so far the enemy does what its supposed to and looks at the player, but when i save my script i am getting this error:
enemymove.cs: error CS0103: The name ‘bullet’ does not exist in the current context, i have checked the line of code and i dont see why there is an issue could someone help me out please see code

using UnityEngine;
using System.Collections;

public class enemymove : MonoBehaviour {

	public Transform LookAtTarget;
	Transform bulletPrefab;  // bullet object
	public float damp = 1.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()
	{
 bullet = Instantiat(bulletPrefab, transform.Find("spawnpoint").transform.position,Quaternion.identity)as Rigidbody;	
 bullet.rigidbody.AddForce(Transform.forward * 1000);
	}

}

Looks like you’re mixing JavaScript and C#.

In C# you have to declare your variables ahead of time. So on line 28 when you use the variable ‘bullet’ it hasn’t been declared yet.

GameObject bullet  = Instantiat(bulletPrefab, transform.Find("spawnpoint").transform.position,Quaternion.identity)as Rigidbody;

Hey MyCroft,

I was actually following a video in C# forgot to decare it as a gameobject, let me try now