Entity.SetVelocity
From GMod Wiki
Function | |
Syntax | Entity:SetVelocity( Vector velocity ) |
Description: | |
Adds the velocity to the existing velocity of an entity. | |
Returns: | nil |
In Object: | Entity |
Realm: | |
BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=Entity.SetVelocity]Entity.SetVelocity [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Examples
Description | Sets the Velocity of a player, similar to PhysObj.ApplyForceCenter. |
---|---|
Used on | |
Code | function SWEP:PrimaryAttack() self.Owner:SetVelocity(self.Owner:GetForward() * 500 + Vector(0,0,1000)) end |
Output | Punches the player forward and upwards. |
Notes
- If the movetype of the entity is MOVETYPE_VPHYSICS (aka, if the entity uses physics simulations) you need to use :SetVelocity on the PHYSICS object of the entity.
- The function actually adds the vector specified to the current velocity, rather than replacing the current velocity.
- Entity:SetLocalVelocity(Vector(x,x,x)) actually sets the Velocity of an entity instead of adding to the entity's current velocity.