- Home /
 
Why does my object disappear?
transform.localScale = new Vector3(size,siee,siee);
 
                
                
               I put that line in funtion Update() and after a few changes (objects is getting smaller while going out) object just disappear (dont know why). Pls help me :(
rest of the code:
using UnityEngine; using System.Collections;
 
               public class scaleIt : MonoBehaviour {
 
                private float farSize = 1.0f;
 private float closeSize = 2.0f; 
 private float possition; //20-320 na Y
 private float piece;
 private float sizee;
 void Update () {
     possition = Mathf.Round(otherscript.possition);
     piece = (close - far)/300; //300px Y size
     sizee = close - (piece * possition);
     // print(close - sizee);
     print(sizee);
     transform.localScale = new Vector3(sizee,sizee,sizee);
 }
  
               }  
               Comment
              
 
               
              I have no idea, but is that the actual script you're using? And is it similar to the "otherscript"-script?
Answer by Justin Warner · Dec 21, 2010 at 08:09 PM
Well, Update() happens every frame, in one second, you can have 30-200 frames, so, you're scaling the object down VERY fast, until it is nothing...
Put a var times = 0, and only let it happen once, by times++ and in the if statement when you need it to do that, have it if times == 0 than do ___.
Your answer