I’m trying to make it so where if there is no more objects in my scene it loads the next scene
but when all the objects are gone it still doesn’t load the scene! Please help.
`using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class next : MonoBehaviour
{
GameObject Page;
// Start is called before the first frame update
void Start()
{
GameObject.FindGameObjectsWithTag(“Page”);
{
Debug.Log(“nice”);
}
else
{
SceneManager.LoadScene(3);
}
}
// Update is called once per frame
void Update()
{
}
}
`
This code shouldn’t even compile, you don’t have a if statement before the else one, also you should test the length of the array returned by FindGameObjectsWithTag, the way you do it right now is just searching for the GameObjects but not doing anything with the returned data…
Something like
if (GameObject.FindGameObjectsWithTag("Page").Length > 0)
Debug.Log("nice");
else
SceneManager.LoadScene(3);
EDIT: You also need to put this code in Update and not in Start so the test is executed once per frame. BUT be aware that the performance will be poor, it’s not recommended to use it every frame. You should better manage your objects using a List or an array and removing the objects from that list when deleting them, and testing the list item number instead of searching the entire scene for objects.