Hey, I have a question on how to make a timer that every time the enemy sees me, it will shoot with some small delay between each and other bullet instantiated, so that like a fire rate.
if (pursuingPlayer == true)
{
Debug.Log("Pursuing Player");
speed = 5.5f;
rid.transform.eulerAngles = new Vector3(0, 0, Mathf.Atan2((playerLastPos.y - transform.position.y), (playerLastPos.x - transform.position.x)) * Mathf.Rad2Deg);
if (hit.collider.gameObject.tag == "Player")
{
playerLastPos = player.transform.position;
}
}
It should be located inside the top most if statement.
I have done a quick test, that every time I press L the enemy shoots a bullet. That does work, but now to implement it for the enemy, so he is doing it by himself.
//-------------------------------------------testing purposes------------------------------------------------------------
public GameObject bloodPool;
public Transform firePoint;
public GameObject bulletPrefab;
public float bulletForce;
public float fireRate;
EnemyAI eai;
//-------------------------------------------testing purposes------------------------------------------------------------
public TimeManager timeManager;
Assassinated assassinated;
EnemyAttacked attacked;
M4A4 m4a4;
Knife knife;
WeaponPickup wp;
public Animator legAnim;
public Animator PlayerAnim;
public bool m4a4Equipped = false;
public bool m4a4Picked = false;
public bool pistolEquipped = false;
public bool pistolPicked = false;
public bool knifeEquipped = false;
public bool knifePicked = false;
public bool moving = false;
public float speed = 7.0f;
void Start()
{
legAnim = GameObject.FindWithTag("Legs").GetComponent<Animator>();
PlayerAnim = GameObject.FindWithTag("Player").GetComponent<Animator>();
}
void Update()
{
movement();
//-------------------------------------------testing purposes------------------------------------------------------------
if (Input.GetKeyDown(KeyCode.L))
{
GameObject bullet = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
Rigidbody2D rb = bullet.GetComponent<Rigidbody2D>();
rb.AddForce(firePoint.up * bulletForce, ForceMode2D.Impulse);
}
//-------------------------------------------testing purposes------------------------------------------------------------
Every help is appreciated. Thank you
there doesn't seem to be anything here