- Home /
 
 
               Question by 
               DangerosoDavo · Jan 23, 2014 at 07:39 PM · 
                javascriptvariabletranslatecopy  
              
 
              Using .Translate() on one variable moves a different var, how? and how do i stop this?
 var newPos : Transform;
 var rayPos : Transform;
 newPos = curTile.transform;
 newPos.Rotate(Vector3(0,(i*30),0));
 newPos.Translate(newPos.forward * 1.6f);
 newPos.Rotate(Vector3(0,(0-(i*30)),0));
 rayPos = newPos;
 rayPos.Translate(rayPos.up * 2);
 
               Using the above script the last line translates the newPos variable, why does it do this, and how can i stop it.
Kind Regards David
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Eric5h5 · Jan 23, 2014 at 07:56 PM
You're setting rayPos as a reference to the newPos variable, so essentially they are the same. If you mean to make rayPos have the same position as newPos, then use transform.position.
Your answer