Ok so I’m making my game have all different maps in one scene and I imagine that having like 10 HUUUGE terrains would affect my performance right?
Well I have this setup: [71011-capture.png*_|71011]
and this function to load the maps, but changing the active state on this many objects is causing a 3 minute lag spike.
var maps : Transform[];
static var loadedMap : int;
var terrain : Terrain;
function LoadMap (index : int){
loadedMap = index;
sunGO.transform.position = maps[index].position;
for(var i=0; i<maps.length; i++){
if(i==index){
sunGO.transform.position = maps*.position;*
_ GameObject.Find(“CloudDome”).transform.position.x = maps*.position.x;_
_ GameObject.Find(“CloudDome”).transform.position.z = maps.position.z;
maps.gameObject.active = true;
terrain = maps.Find(“Terrain”).GetComponent.();
}else{
maps.gameObject.active = false;
}
}
}
Now I should give a little background on what this function does.
The “terrain” variable is simply what my walking sound script uses to check what terrain I’m on and then get the texture I’m on, nothing related to my question.
“CloudDome” is that thing you see in the distance on the main map.
“sunGO” is the GameObject that holds the sun, moon, weather, and other ambient things.
The “maps” variable is what holds the Tranform parents of the maps, see it here:
[71012-capture.png*|71012]*
Now if it froze just when loading a map, that would be fine, but it freezes as soon as I host a server because it’s setting all of the other maps (only 2 maps at the time) to be inactive.
I apologize for this being so long, please help me fix this or at least come up with a workaround.
Thanks in advance!
*
*