I have this script that lets enemy AI shoot instantly whenever they are in range with the player, the problem is, I dont want them to instantly shoot but take their time to aim like a real life person aiming a gun
public override void Awake()
{
base.Awake();
}
public override void Attack()
{
base.Attack();
if (!weaponRanged.canAttack)
return;
if (weaponRanged.isReloading)
return;
if (weaponRanged.currentAmmo <= 0)
{
StartCoroutine(weaponRanged.Reload(weaponRanged.reloadTime));
return;
}
else
{
weaponRanged.currentAmmo--;
GameObject bullet = Instantiate(weaponRanged.bulletPrefab, weaponRanged.attackPoint.position, weaponRanged.attackPoint.rotation);
bullet.GetComponent<bulletEnemy2>().creator = gameObject;
}
}
this is the base.Attack();
public virtual void Attack()
{
if (Time.time >= nextTimeToFire)
{
nextTimeToFire = Time.time + 1f / attackSpeed;
canAttack = true;
}
else
{
canAttack = false;
}
}