Hello so i have a random generating terrain which is nice, but the world is so big so if every gameobject whould be visable at the same time the game would crash. So i made a script where i dissable around 90% of all the gameobjects. There is a sphere on my player which is tagged, and if the object is outside that sphere it’s components will be set to false. It works fine but i still have 3 fps. Tho almost every visable gameobject is set to false. Is it because the gameobject is still in the scene? Because if it is i have no idea how to fix the lag. Thanks :))
using UnityEngine;
using System.Collections;
public class DisplayVegetation : MonoBehaviour {
public GameObject[] items;
void Start ()
{
for(int i = 0; i < items.Length; i++)
{
items*.SetActive(false);*
-
}* -
}*
-
void OnTriggerStay(Collider coli)*
-
{*
-
if (coli.tag == "ShowVegetation")* -
{* -
for(int i = 0; i < items.Length; i++)* -
{*
_ items*.SetActive(true);_
_ }_
_ }_
_ }*_
* void OnTriggerExit(Collider coli)*
* {*
* if (coli.tag == “ShowVegetation”)*
* {*
* for(int i = 0; i < items.Length; i++)*
* {*
_ items*.SetActive(false);
}
}
}
}*_