i have a function FindThings() that compares lots of Vector3’s found with findWithTag to one global var PlayerLocation:Vector3 from the top of the script
it seems that if FindThings() calls PlayerLocation multiple times from the global variables, it goes slower than if PlayerLocation is sent to the function as a function variable:
FindThings(PlayerLocation);
{
Do various PlayerLocation comparisons;
}
is faster than
var PlayerLocation:Vector3;
FindThings()
{
Do various PlayerLocation comparisons;
}
EDIT: this function is going very slowly, it was even slower when location was a global variable. i have another version of the same function that goes 100 times faster. it’s odd.
function delAdjoining(location: Vector3)//Dell all walls surrounding a space if revisited prior to rebuilding
{
for (var j:int = 0; j < neighbours.length; j ++)
{
if ( neighbours[j] == location )
{
var dwalls = GameObject.FindGameObjectsWithTag ("wall");
for (var dwall in dwalls)
{
if(dwall.transform.position == (location + stp1*.5*sizeMult)){Destroy(dwall);}
if(dwall.transform.position == (location + stp2*.5*sizeMult)){Destroy(dwall);}
if(dwall.transform.position == (location + stp3*.5*sizeMult)){Destroy(dwall);}
if(dwall.transform.position == (location + stp4*.5*sizeMult)){Destroy(dwall);}
if(dwall.transform.position == (location + stp5*.5*sizeMult)){Destroy(dwall);}
if(dwall.transform.position == (location + stp6*.5*sizeMult)){Destroy(dwall);}
print("erased adjoining");
}
break;
}
}
}