Angle/SnapTo

From Garry's Mod
Jump to: navigation, search
 Angle:SnapTo( )

Contents

Description

Snaps the angle to nearest interval of degrees.

NOTE

This will modify the original angle too!

Arguments

string axis

The component/axis to snap. Can be either "p"/"pitch", "y"/"yaw" or "r"/"roll".

Arguments

number target

The target angle snap interval

Returns

Angle

The snapped angle.

Examples

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 )
Personal tools
Navigation