transform problem

hello,
I cant understand why the copy of position transform dont take care of the fractional part

function Awake () 
{
 	        Debug.Log("current"); 
 	        Debug.Log(transform.position);
transform.position = GameObject.Find("reference").transform.position;

 	        Debug.Log("current"); 
 	        Debug.Log(transform.position);
 	        Debug.Log("reference");
 	        Debug.Log(GameObject.Find("reference").transform.position);
}

> current
(-1394.2, 3579.4, -14196.6)
UnityEngine.Debug:Log(Object)
cam:Awake() (at Assets/cam.js:5)

> current
(-1394.2, 3573.1, -14197.0)
UnityEngine.Debug:Log(Object)
cam:Awake() (at Assets/cam.js:7)

> reference
(-1394.6, 3573.3, -14197.0)
UnityEngine.Debug:Log(Object)
cam:Awake() (at Assets/cam.js:9)

thank you

(edit : :slight_smile: )

When you use Debug.Log on a vector, it gets converted to a string first, and vector to string conversions cause the numbers to be rounded quite a lot. Try printing out the x, y and z members of the vector separately to see what the precise values are. For clarity, this only affects how the numbers are displayed; it doesn’t affect their actual values.

You might still see some minor differences in certain circumstances due to floating point error, but it should be a lot closer to what you expect.

thanks for your reply,

if I point your attention on the problem it is because I can see the consequences on my game view.

objets I want to be aligned are not.

I printed the floats separatly and obtained the same result

transform.position = GameObject.Find("reference").transform.position;
 	        transform.Translate(0,0,-7);
 	        Debug.Log("current"); 
 	        Debug.Log(transform.position.x);
 	        Debug.Log(transform.position.y);
 	        Debug.Log(transform.position.z);
 	        Debug.Log("reference");
 	        Debug.Log(GameObject.Find("reference").transform.position.x);
 	        Debug.Log(GameObject.Find("reference").transform.position.y);
 	        Debug.Log(GameObject.Find("reference").transform.position.z);


>x
-1394.172
UnityEngine.Debug:Log(Object)
cam:Awake() (at Assets/cam.js:11)
>y
3573.067
UnityEngine.Debug:Log(Object)
cam:Awake() (at Assets/cam.js:12)
>z
-14189.96
UnityEngine.Debug:Log(Object)
cam:Awake() (at Assets/cam.js:13)


>x
-1394.592
UnityEngine.Debug:Log(Object)
cam:Awake() (at Assets/cam.js:15)
>y 
3573.298
UnityEngine.Debug:Log(Object)
cam:Awake() (at Assets/cam.js:16)
>z 
-14189.98
UnityEngine.Debug:Log(Object)
cam:Awake() (at Assets/cam.js:17)

oups, forget my mistake I was applying differents conditions in my script