Entity/SetGroundEntity

From Garry's Mod
Jump to: navigation, search
 Entity:SetGroundEntity( )

Contents

Description

Sets the ground the entity is standing on.

Arguments

Entity ground

The ground entity.

Examples

Example

Gives all players the ability to (sort of) walk on water.

-- shared.lua tick
function GM:Tick()
	
	local trace = {}
	local world = Entity( 0 )
	
	for p, ply in pairs( player.GetAll() ) do
	
		trace = util.TraceLine( {
			start = ply:GetPos() + Vector( 0, 0, 72),
			endpos = ply:GetPos() + Vector( 0, 0, -3 ),
			mask = MASK_WATER,
			filter = function( ent ) return true end
		} )
		
		if( trace.Hit ) then
			ply:SetGravity( 0.0001 )
			ply:SetGroundEntity( world )
		else
			ply:SetGravity( 1.0 )
		end
		
	end
	
end


Personal tools
Navigation