//FireScript



    [SerializeField] private GameObject bullet;
    [SerializeField] private Transform spawnPoint;
    [SerializeField] private float bulletSpeed = 25f;

    public void FireBullet()
    {
        GameObject spawnBullet = Instantiate(bullet, spawnPoint.position, spawnPoint.rotation);
        spawnBullet.GetComponent<Rigidbody>().velocity = spawnPoint.forward * bulletSpeed;
        Destroy(spawnBullet, 5f);
    }










//TargetScript



    public GameObject targetPrefab;
    
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.CompareTag("Bullet"))
        {
            SpawnNewTarget();
            Destroy(gameObject);
        }
    }

    void SpawnNewTarget()
    {
        float x = Random.Range(-5f, 5f);
        float y = Random.Range(0, 5f);
        float z = -6f;

        var randomPosition = new Vector3(x, y, z);

        Instantiate(targetPrefab, randomPosition, Quaternion.Euler(90, 0, 0));
    }
