Garry's Mod Wiki

Garry's Mod Wiki

  number math.SnapTo( number input, number snapTo )

Description

Snaps a number to the closest multiplicative of given number. See also Angle:SnapTo.

Arguments

1 number input
The number to snap.
2 number snapTo
What to snap the input number to.

Returns

1 number
The clamped value.

Example

Example usage

print( math.SnapTo( 0, 15 ) ) print( math.SnapTo( 10, 15 ) ) print( math.SnapTo( 20, 15 ) ) print( math.SnapTo( 22.2, 15 ) ) print( math.SnapTo( 22.5, 15 ) ) print( math.SnapTo( 43, 15 ) )
Output:
0 15 15 15 30 45

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated four times a day. Edits and history are not available.

Last Parsed: Loading...