Gamemode.ShouldCollide

From GMod Wiki

Jump to: navigation, search
Event Hook
Hook NameShouldCollide
SyntaxGM:ShouldCollide( Entity entity1, Entity entity2 )
DescriptionCalled to poll if two entities should collide.
ReturnsBoolean
Lua StateNewerShared.png
BBCode[b][url=wiki.garrysmod.com/?title=Gamemode.ShouldCollide]Gamemode.ShouldCollide [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionStops all players from colliding with eachother.
Used onNewerShared.png
Code
 
local function ShouldCollideTestHook( ent1, ent2 )
 
	if ( ent1:IsPlayer() and ent2:IsPlayer() ) then
		return false //Returning false stops the entities from colliding
	end 
	-- DO NOT RETURN FALSE HERE OR YOU WILL FORCE EVERY OTHER ENTITY NOT TO COLLIDE
end
hook.Add( "ShouldCollide", "ShouldCollideTestHook", ShouldCollideTestHook )
OutputN/A


Notes

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox