Враг не стреляет
Вот скрипт
public Transform player;
[SerializeField] GameObject rifleStart;
[SerializeField] GameObject Bullet;
float area = 100;
public float shootsp = 50;
float timer = 0;
[SerializeField] float cooldown = 1;
// Start is called before the first frame update
void LateUpdate()
{
transform.LookAt(player.transform.position);
}
void Update()
{
if (Vector3.Distance(transform.position, player.transform.position) < area)
{
transform.LookAt(player.transform);
timer += Time.deltaTime;
if (timer > cooldown)
{
timer = 0;
GameObject buf = Instantiate(Bullet);
Vector3.Distance(transform.position, Bullet.transform.position * shootsp * Time.deltaTime);
//transform.forward * shootsp;
buf.GetComponent<Bullet>().setDirection(transform.forward);
buf.transform.position = rifleStart.transform.position;
buf.transform.rotation = transform.rotation;
Destroy(buf, 5);
}
}
}