Angle.RotateAroundAxis
From GMod Wiki
Revision as of 03:28, 23 June 2011 by Colonel Thirty Two (Talk | contribs)
| Function | |
| Syntax | Angle:RotateAroundAxis( Vector vAxis, Float fDegrees ) |
| Description: | |
| Rotates this angle about the axis formed by the vector vAxis by the given number of degrees (not radians). | |
| Returns: | nil |
| In Object: | Angle |
| Realm: |
|
| BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=Angle.RotateAroundAxis]Angle.RotateAroundAxis [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Examples
| Description | Spawn a portalrift effect (Example should be used within a SWEP for 'self.Owner' to mean anything) |
|---|---|
| Used on | |
| Code |
// Spawn a portalrift effect normal to the player's aim vector (parallel with the
// player's Up vector) AND FACING the player (that's why we need to rotate the angle ;) )
// vAngle is the player's aim vector
local vAngle = self.Owner:GetAimVector()
// Some screwed up object obfuscation: the angle of the up vector
// of the angle of the vector... Get that? :D
local UpAngle = vAngle:Angle():Up():Angle()
// The original UpAngle
Msg("UpAngle was: " .. tostring(UpAngle) .. "\n")
// Rotate UpAngle around the up vector axis
UpAngle:RotateAroundAxis(vAngle:Angle():Up(), 180)
// The Rotated UpAngle
Msg("UpAngle is now: " .. tostring(UpAngle) .. "\n")
local rifteffect = ents.Create( "prop_dynamic" )
// Give the prop_dynamic the portalrift model
rifteffect:SetModel( "models/Effects/portalrift.mdl" )
rifteffect:SetPos( self.Owner:GetShootPos() )
rifteffect:SetAngles( UpAngle )
rifteffect:Spawn()
// Don't draw the shadow for the effect
rifteffect:DrawShadow( false )
|
| Output | Spawns a portalrift effect facing the player when shooting a SWEP. Note that the RotateAroundAxis method performs it's rotation on the Angle Object that called it. Notice that UpAngle is different before the rotation than it is afterwards. |
Additional Notes
- This method does not return anything. It is modifying the Angle you are calling RotateAroundAxis on.
See Also
- Angle (Object)