I have turrets placed that need cameras CREATED on top of them when I press a button.
The button works fine and the cameras are all created with a number after their name so I can select them differently.
Now my issue is the cameras are off by default, and i cant seem to “FIND THEM” using FindGameObjectsWithTag unless they are already ENABLED in the inspector.
What do I do to control a camera that is in an array as a game object?
Im confused. Here is some of my code and I cannot find out how to enable cameras based on their number. I have no idea where to even start. Ive been trying all sorts of stuff but none of it makes sense. THis function below is suppose to delete all cameras before making them based on how many turrets exist. So if i have 4 turrets, this makes 4 cameras.
void GetTurrets()
{
turretCamerasDestroyed = GameObject.FindGameObjectsWithTag("TurretCamera");
foreach (GameObject camera in turretCamerasDestroyed)
{
Destroy(camera);
}
turretCameras = GameObject.FindGameObjectsWithTag("Turret");
//turretCount = 0;
foreach (GameObject turret in turretCameras)
{
turretCount += 1;
var newCamera = (GameObject)Instantiate(newCameraPrefab, turret.transform);
newCamera.name = "Turret Camera " + turretCount;
}
}