Garry's Mod Wiki

Entity:AlignAngles

  Angle Entity:AlignAngles( Angle from, Angle to )

Description

Returns an angle based on the ones inputted that you can use to align an object.

This function doesn't change the angle of the entity on its own (see example).

Arguments

1 Angle from
The angle you want to align from
2 Angle to
The angle you want to align to

Returns

1 Angle
The resulting aligned angle

Example

This example will make ent1 face up from ent2.

ent1:SetAngles(ent1:AlignAngles(ent1:GetForward():Angle(), ent2:GetUp():Angle()))
Output: Sets ent1's angle to one where ent1 faces up from ent2.