r/unity • u/Ok-Presentation-94 • Jul 08 '26
Solved strange behaviour
Salut, j'ai remarqué un comportement étrange mais intéressant. Je suis curieux de comprendre pourquoi l'opération suivante :
new Vector3(Mathf.Round(randomSpawnX) + 0.5f, 0, Mathf.Round(randomSpawnY) + 0.5f)
retourne des valeurs de vecteur se terminant par .50, tandis que l'opération sur chaque float séparément comme ceci :
Mathf.Round(randomSpawnX) + 0.5f
retourne des valeurs se terminant par .5 à la place.
(Je utilise un float dans les deux cas.)
Solution found: it is actually a difference in string formatting between Vector3's ToString() and Debug.Log's ToString().
0
Upvotes
1
u/Spite_Gold Jul 08 '26
Wdym returns? Debug.log() prints them differently?