Entity.GetForward

From GMod Wiki

Revision as of 19:32, 27 October 2011 by nüke (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax Entity:GetForward( )
Description:
Get the forward vector of an entity.
Returns: Vector
In Object: Entity
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Entity.GetForward]Entity.GetForward [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionThis is an example of the usage of GetForward on a player in a SWEP.
Used onNewerServer.png
Code
 
function SWEP:Think()
 
    if not SERVER then return end //This makes the following code only run on the server
 
    if self.Owner:OnGround() then //check if the player is on the ground
 
        self.Owner:SetVelocity( self.Owner:GetForward() * 200 + Vector( 0, 0, 200 ) ) //set the velocity to launch the player forward and up.
 
    end
 
end 
 
OutputPropels the SWEP owner forward.


See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox