Entity/EnableCustomCollisions

From Garry's Mod
Revision as of 21:20, 1 June 2016 by Rtm516 (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
 Entity:EnableCustomCollisions( )

Contents

Description

Flags an entity as using custom lua defined collisions. Fixes entities having spongy player collisions or not hitting traces, such as after Entity:PhysicsFromMesh

Arguments

boolean useCustom

True to flag this entity

Examples

Example

Creates a mesh table, and assigns it as the entity's collisions

function ENT:ProceduralPlatform()
	local VERTICES = {},
	for x = 1, 32, 1, do
		for y = 1, 32, do
			table.insert( VERTICES, { pos = ( self:GetPos() + Vector( 0, 0, 1 ) ) } );
			table.insert( VERTICES, { pos = ( self:GetPos() + Vector( 0, y, 1 ) ) } );
			table.insert( VERTICES, { pos = ( self:GetPos() + Vector( x, y, 1 ) ) } );

			table.insert( VERTICES, { pos = ( self:GetPos() + Vector( 0, 0, 1 ) ) } );
			table.insert( VERTICES, { pos = ( self:GetPos() + Vector( x, y, 1 ) ) } );
			table.insert( VERTICES, { pos = ( self:GetPos() + Vector( x, 0, 1 ) ) } );
		end
	end
	self:PhysicsFromMesh( VERTICES );
	self:GetPhysicsObject():EnableMotion( false );
	self:EnableCustomCollisions( true );
end


Personal tools
Navigation