How to set x to the nearest multiplier of y

Godot Version

4.5

Question

the name of the topic says it all honestly, how do i set the value of x to the nearest multplier of y?

any help is appreciated!

-Quinn Jusufi <3

Use snapped()

so if you need to like snap x to the nearest multiplier of y then you should do something like:

x = round(x / y) * y

yeah, but how? im genuinely confused on how i should do that

x = snapped(x, y)