So while trying to script something that could check how many prefabed game objects have been destroyed from the spawner script, I came across an error saying I wouldn’t convert a class to an integer. This shouldn’t have been a problem because the tutorial where I got this encountered the same error and fixed it with putting .Length at the end of the line. So I do this and I get an error saying that the class that the line of code is referencing doesn’t have a definition for Length. So then I played around with it and I think the line thinks that I’m trying to call on a variable from a different class. Any help would nice (also if you couldn’t tell, I’m pretty new to all of this)
TLDR: .Length is being a butt plz help (Line 27)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Spawner : MonoBehaviour
{
public GameObject wallPrefab;
private int randWall;
private float spawnWait;
public float spawnFreq = 10;
public int wallCount;
// Start is called before the first frame update
void Start()
{
InvokeRepeating("SpawnWall", 0, spawnFreq);
}
// Update is called once per frame
void Update()
{
wallCount = FindObjectOfType<Wall>().Length;
if (wallCount == 0)
{
spawnFreq = spawnFreq - 0.5f;
}
}
void SpawnWall()
{
Vector3 spawnPos = new Vector3(Random.Range(-10, 10), 1.5f, 0);
Instantiate(wallPrefab, spawnPos, wallPrefab.transform.rotation);
}
}