Angle.RotateAroundAxis

From GMod Wiki

Jump to: navigation, search
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: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Angle.RotateAroundAxis]Angle.RotateAroundAxis [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionSpawn a portalrift effect (Example should be used within a SWEP for 'self.Owner' to mean anything)
Used onNewerServer.png
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 ) 
 
OutputSpawns 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

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox