0
\$\begingroup\$

I round my transform.position to the nearest integer at the end of every frame so it's never a decimal number. I would like to know if there's a way to make unity store the position in ints instead of floats to prevent floating points precision problems.

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

No, you can't do that because Unity is doing all its internal calculation in float.

But if you would like to implement your game mechanics completely with integer arithmetics, you could write your own Vector3Int class, use it for all of your game mechanics, and then have each of your game objects write its Vector3Int-position to transform.position in LateUpdate().

\$\endgroup\$
0
\$\begingroup\$

Assuming that you mean a Vector3 type that uses ints, I don't think there is a type that uses ints as internal storage seeing as how the unity transform system all uses floats everywhere.

\$\endgroup\$

You must log in to answer this question.