i need to put an entire variable to be rounded to the nearest number

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By tonykkjk

I’m making an Indie game, so I wanted to put my variable “coins” rounded because it’s getting more than 5 decimals when its value is multiplied, I tried using the “floor” and “stepify” function but I don’t understand how they do it. because I’m still new to Godot Engine.

I’m brazilian, so i’m using google translate to do this.

:bust_in_silhouette: Reply From: wyattb

Did you try something like this:

var x: float= 1.7
var y: int=int(x);

or this for rounding up or down

var x: float= 1.4233
var y: int=round(x);

Thx man, you saved my entire game

tonykkjk | 2021-06-06 01:11