Hi in the script below I am accessing my Score_Control_Script in order to change a variable inside it, but when I do it this way it cause a lag in my game (I am doing this same thing with the UIControllerScript), not a big one but every time that piece of code runs which is quite often in my game it causes the entire thing to freeze for about a half a second and then unfreeze?
I have used this method many times before and it works just fine so I do not know what the problem is? Thank you for your help in advance (:
var scoreControlScript : Score_Control_Script;
var scoreValue = 1;
var scoreSound : AudioClip;
// Used to disable sound fx when user disables sound fx button
var UIControllerScript : UIController;
function OnTriggerEnter2D (other : Collider2D)
{
switch (other.tag) {
case "ScoreCollider":
if (!gameover) {
scoreControlScript.currentScore += scoreValue;
if (UIControllerScript.muteSoundEffects == false) {
audio.PlayOneShot(scoreSound, 0.3);
}
}
break;
case "Respawn":
Destroy(gameObject);
break;
default:
Debug.Log("Enemy_Controller_Script - OnTriggerEnter2D: switch statement didn't find any tag");
}
}
}