How do I Round a transform.position.y from its float to the nearest whole int?

I am trying to make a points system based on the player’s y position

Points = transform.position.y;
Points = Math.Round(Points);
GUI.Label(new Rect(10, 10, 100, 20), "Level : " + Points);

That is what google said was the soloution. It doesn’t work.

What does not work? What is the expected behavior? What happens instead?

1 Like

I was hoping this code would change the float of the player’s position to a full integer which would be stored in the variable Point. all I get is an error messsage. It says that Math doesn’t exist in the current context.

Use Mathf instead of Math.

1 Like

Just so you know, GUI.Label and the whole code-based GUI system is pretty old and no one ever liked it. The new “canvas” system allows you to just drag in a label (text), like a gameObject. It just says what it says and can be changed with (more-or-less) label1.text=“new value”;