- Home /
 
how do i make this lag less?
i have a script to make a breakable building and i attach it to every part so when a certain amount of force is applied it "breaks" i have the script attached to a small brick wall and the game goes at about 5fps, does anyone know how i can make it lag less?
 var startx : float = 0;
 var starty : float = 0;
 var startz : float = 0;
 var breakdistance : float = 0.5;
 var broken = 0;
 
 function Start () {
 rigidbody.freezeRotation = true;
 rigidbody.useGravity = false;
 startx = transform.x;
 starty = transform.y;
 startz = transform.z;
 Invoke("Loop",0.2);
 }
 
 function Update () {
 if(transform.x >= startx + breakdistance){
 Break();
 }
 if(transform.x <= -startx - breakdistance){
 Break();
 }
 if(transform.y >= starty + breakdistance){
 Break();
 }
 if(transform.y <= -starty - breakdistance){
 Break();
 }
 if(transform.z >= startz + breakdistance){
 Break();
 }
 if(transform.z <= -startz - breakdistance){
 Break();
 }
 }
 
 function Loop () {
 Invoke ("Loop",0.2);
 if(broken == 1){
 transform.x = startx;
 transform.y = starty;
 transform.z = startz;
 }
 }
 
 function Break () {
 broken = 1;
 rigidbody.useGravity = true;
 rigidbody.freezeRotation = false;
 }
 
              
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by sam32x · Jul 19, 2012 at 07:38 AM
nvm i fixed it
If you fixed it, could you please provide your solution? This is to keep the information on this board properly searchable. :P I.e., if someone googles for "Unity fix lag" in the future and it leads them to this post, the answer should be something else than "nvm i fixed it".
Your answer