Entity.OBBMins

From GMod Wiki

Revision as of 08:33, 18 October 2009 by Unrealomega (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax Entity:OBBMins( )
Description:
Returns the low corner of an entity's OBB as a local vector. The "min" is the vertex that has the min extents of all axises in it.
Returns: Vector
In Object: Entity
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Entity.OBBMins]Entity.OBBMins [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionUse the z component of OBBMins to place the bottom of the entity exactly against the surface, by multiplying it by the normal vector.
Used onNewerMissing.png
Code
function TOOL:UpdateGhostWireKeyboard( ent, player )
 
	if ( !ent || !ent:IsValid() ) then return end
 
	local tr 	= utilx.GetPlayerTrace( player, player:GetCursorAimVector() )
	local trace 	= util.TraceLine( tr )
 
	if (!trace.Hit || trace.Entity:IsPlayer() || trace.Entity:GetClass() == "gmod_wire_keyboard" ) then
		ent:SetNoDraw( true )
		return
	end
 
	local Ang = trace.HitNormal:Angle()
	Ang.pitch = Ang.pitch + 90
 
	local min = ent:OBBMins()
	ent:SetPos( trace.HitPos - trace.HitNormal * min.z )
	ent:SetAngles( Ang )
 
	ent:SetNoDraw( false )
 
end
OutputN/A


Additional Notes

Orientated Bounding Box with local coordinate setup.

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox