Entity.NearestPoint

From GMod Wiki

Revision as of 21:34, 25 December 2009 by Nerdboy (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax Entity:NearestPoint( Vector given )
Description:
Returns the closest point on the edge of the entity's bounding box to the given vector. See the image in Additonal Notes for more information.
Returns: Vector
In Object: Entity
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Entity.NearestPoint]Entity.NearestPoint [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionWhen picked up with the gravity gun, sparks will emit in front of the player.
Used onNewerServer.png
Code
function SparkPickup( ply, ent )
	local sparkarea = ent:NearestPoint( ply:GetShootPos() )
 
	local ed = EffectData()
	ed:SetOrigin( sparkarea )
	ed:SetScale( 1 )
	util.Effect( "Sparks", ed )
end
 
hook.Add( "GravGunOnPickedUp", "SparkPickup", function( ply, ent ) SparkPickup( ply, ent ) end
OutputSparks emit in front of the player when an entity is picked up.


Additional Notes

Nearest point towards vector.
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox