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);
}
}