- Home /
Unity 4.0 Crashes without reason
It always crashes every 20 seconds during the gameplay. I also check all the code by deactivating them to find what is the problem.
I checked all, and it still crashes every 20 seconds. I didn't make any changes today, yesterday, my Unity is fine.
When it start crashes, i check the taskmanager, and it says Unity used 394,000MB (4GB DDR3 installed, 3GB usable) of memory and 25% cpu usage (Intel Corei3)
please help me.
thanks.
$$anonymous$$aybe you have something currupted, or you have a big fail in your code that make the process overload.
I had a similar problem... try creating a new project with nothing but that annoying capsule first person controller that comes with unity with a flat terrain and test that. if your still experiencing problems Unity is probably corrupted or stuck in some weird fatal error. which means you need to re-install Unity.
if it works then your code, a bad asset or the project itself is at fault. to fix this issue, create a new project and just move over all the Non-script assets and probably review your code for any really bad things(e.g preloading all assets and duplicating when needed).
I've had about 7 projects just go kaput on me and having move everything (over 30 gigs lol). I don't know why this happens, but it its started way back at Unity 3.2
This is the latest thing i've done before the crashes
if(theFader){//runs in lateupdate function
if(theFader.guiTexture.color.a > 0) theFader.guiTexture.color.a -= Time.deltaTime /3;
else Destroy(theFader);
}
function Sort$$anonymous$$eUp(lap : int){//runs in update function if(lap == 1){ var counter1 = 0; for(var lpn1 = 0; lpn1 < absentChecker.Length; lpn1++){ if(absentChecker[lpn1]){ counter1++; lap1[counter1] = pl1[lpn1]; } }
for(var l1p in lap1) if(l1p == 0) l1p = 100000;
lap1.Sort(lap1,1,8);
}//till lap10
}
//below is other script. runs in update function
player.nextWaypoint.Sort$$anonymous$$eUp(currentLap);
if(currentLap == 1){
for(var l1 = 0; l1 < player.nextWaypoint.lap1.length; l1++){
if(distanceToWaypoint == player.nextWaypoint.lap1[l1]) currentRank = l1;
}
}
I suspected the AI kart is the main problem, because I've tested, play this game without AIs. But i didn't do any changes to AI.
you can try updating Unity , though i doubt it will help... I'm unsure what you code even does..(lap1?, nextwaypoint?) only that it has to do with racing. If you tried what I said above with no improvement then the only thing i can think of left is to rely on Bug Reports.
Answer by LAiKA787SV · Apr 27, 2013 at 05:19 PM
Last time i check, this was the problem of Unity's crash!
function OnCollisionEnter(col : Collision){
if(!moveNow && useTranslator && rigidbody && onColliderGo){
moveNow = true;
Destroy(rigidbody);
useTranslator = true;
}
if(explosionType == ExplosiveTypes.TNT){
if(col.gameObject.tag == "Player"){
col.transform.root.GetComponent(Kart).PlantTNT(gameObject);
isTNT = true;
}
if(col.gameObject.tag == "Opponent"){
col.transform.root.GetComponent(AIKart).PlantTNT(gameObject);
isTNT = true;
}
}else if(explosionType == ExplosiveTypes.Nitro){
if(col.gameObject.tag == "Player" || col.gameObject.tag == "Opponent")Explode();
}
else if(explosionType == ExplosiveTypes.Other){
if(col.gameObject.tag == "Player" || col.gameObject.tag == "Opponent" || col.gameObject.tag == specialTag)Explode();
}
else if(explosionType == ExplosiveTypes.Ice){
if(col.gameObject.tag == "Player" || col.gameObject.tag == "Opponent")FreezeMe(col.gameObject);
}
else if(explosionType == ExplosiveTypes.FryingPan){
if(col.gameObject.tag == "Player" || col.gameObject.tag == "Opponent" || col.gameObject.tag == specialTag){
if(powerPan) StopMe(col.gameObject,5);
else StopMe(col.gameObject, 1);
}
}
else if(explosionType == ExplosiveTypes.BouncyJr){
if(col.gameObject.tag == "Player" || col.gameObject.tag == "Opponent" || col.gameObject.tag == "Environtment"){
if(bouncyJrCounter > 10) Explode();
else bouncyJrCounter ++;
}
}
else if(explosionType == ExplosiveTypes.Cake){
if(col.gameObject.tag == "Player" || col.gameObject.tag == "Opponent")StickMe(col.gameObject);
}
}
function OnTriggerEnter(col : Collider){
if(explosionType == ExplosiveTypes.Glue){
if(col.gameObject.tag == "Player" || col.gameObject.tag == "Opponent")GlueMe(col.gameObject,powerGlue);
}
if(explosionType == ExplosiveTypes.Oil){
if(col.gameObject.tag == "Player" || col.gameObject.tag == "Opponent")SpinMe(col.gameObject);
}
}