Garry's Mod Wiki

Angle:SnapTo

Angle Angle:SnapTo( string axis, number target )

Description

Snaps the angle to nearest interval of degrees.

This will modify the original angle too!

Arguments

1 string axis
The component/axis to snap. Can be either "p"/"pitch", "y"/"yaw" or "r"/"roll".
2 number target
The target angle snap interval

Returns

1 Angle
The snapped angle.

Example

Example usage

print( Angle( 0, 92, 0 ):SnapTo( "y", 90 ) ) print( Angle( 0, 115, 0 ):SnapTo( "y", 45 ) ) print( Angle( 12, 98, 167 ):SnapTo( "p", 30 ):SnapTo( "y", 45 ):SnapTo( "r", 45 ) )
Output:
Angle( 0, 90, 0 ) Angle( 0, 135, 0 ) Angle( 0, 90, -180 )

Page Links


Special Pages


Wikis

?

Render Time: 64ms

DB GetPage 3
Generate Html 8
SaveChanges 39
Render Body 0
Render Sidebar 11