Hi there,
Is there anyway a List, gathering, and removing items, no more than 50 at a time (of renderers), would cause any type of choke, a performance choke?
The reason I ask, is, I have a system which gathers a list of renderers when triggered (takeDamage()). This system works fine, but with each successive hit, the removal of the list items, (rednerer.enabled = false), delays. So, first hit, fine. Second hit, slight delay, third hit a greater delay and so on.
Can some one look at this code and see if they can notice anything?
Thanks
public void handleDamage(float damageGiven){
print("////////////////////" + Time.time);
print("TIME A " + Time.time);
///gather damage taken
energyUsedTotal += damageGiven;
//apply it to 100% ratio
energyUsedRatio = energyUsedTotal/energyLimit;
//determine the nodes of energy bar to remain enabled and disabled (renderer)
if(energyUsedRatio >= 1f){
///if here, brain has died.
killPlayer();
}
for(int i = 0; i < energyNodesLength; i++){
if((float)i / (energyNodesLength - 1) > energyUsedRatio){
energyNodes[i].enabled = true;
}
else{
//add this node to a list.
healthBarAnimList.Add(energyNodes[i]);
print("//////healthBarAnimList.Count " + healthBarAnimList.Count + " " + Time.time);
}
}
//now animate the healthBarAnimList down.
print("///INVOKGING ANIM HEALTH BAR " + Time.time);
InvokeRepeating("animateHealthBarAnimListDown", 0,0.1f);
}
void animateHealthBarAnimListDown(){
print("\\\\\\\\\\\\\\\\" + Time.time);
print("TIME B " + Time.time);
print("\\healthBarAnimList.Count" + healthBarAnimList.Count + " " + Time.time);
print("\\");
if(healthBarAnimList.Count == 0){
print("\\Count AT 0... Cancel ANIM");
CancelInvoke("animateHealthBarAnimListDown");
return;
}
energyNode = healthBarAnimList[0];
healthBarAnimList.RemoveAt(0);
energyNode.enabled = false;
}