Hello, it has been a while since i visited this site anyways. So I’m testing my game right? And in my boss battle, it freezes right when i hit it with a missile and i have to force close unity to restart! So I build an application and test it and after it froze i looked at the output log in the app’s data folder and the last thing it print:
Skipped rendering frame because GfxDevice is in invalid state (device lost)
so apparently i have too many missiles going on. How should i fix this?! I don’t have any other ideas without missiles.
When you instantiate missiles and other projectiles, usually you must give them a limited life time: destroy them after some time or when they are no more visible (out of camera view), like this (attach to the projectile):
function Start(){
Destroy(gameObject, 15); // missile suicides after 15s
}
function OnBecameInvisible(){
Destroy(gameObject);
}
This ensures that missiles which don’t hit anything will be silently destroyed and no more waste memory and processing time.
But I suspect your problem may have a different cause, like something being instantiated repeatedly in some Update function.
Another frequent freezing cause is endless loops, sometimes caused by logic errors, other by yield instructions that are missing or are never reached,