so i have two vectors that are getting compared with Vector3.distance which is coming out right, but when i try to compare it in a for loop like this
it goes completely crazy it instantiates like 20 or so every frame and it wont stop. i think this has to do with distance internally, but i dont know could some one with more knowledge help me out
If that loop is in Update and your two objects are at a distance 20, obviously you'll got 20 instanciations every frame. You should do that somewhere else, triggered by some event (clic, collisions, etc).
By the way, when you compare vector, you should use the sqrMagnitude instead of distance, so you can spare yourself 2 sqrt.
answered Feb 13 '12 at 04:49 AM