Garry's Mod Wiki

GM:ShouldCollide

boolean GM:ShouldCollide( Entity ent1, Entity ent2 )
This hook is predicted. This means that in singleplayer, it will not be called in the Client realm.

Description

Called to decide whether a pair of entities should collide with each other. This is only called if Entity:SetCustomCollisionCheck was used on one or both entities.

Where applicable, consider using constraint.NoCollide instead - it is considerably easier to use.

This hook must return the same value consistently for the same pair of entities. If an entity changed in such a way that its collision rules change, you must call Entity:CollisionRulesChanged on that entity immediately - not in this hook.
This hook can cause all physics to break under certain conditions.

Issue Tracker: 642

Arguments

1 Entity ent1
The first entity in the collision poll.
2 Entity ent2
The second entity in the collision poll.

Returns

1 boolean
Whether the entities should collide.

Example

This should always return true unless you have a good reason for it not to.

hook.Add( "ShouldCollide", "CustomCollisions", function( ent1, ent2 ) -- If players are about to collide with each other, then they won't collide. if ( ent1:IsPlayer() and ent2:IsPlayer() ) then return false end -- We must call this because anything else should return true. return true end )

Page Links


Special Pages


Wikis

?

Render Time: 51ms

DB GetPage 3
Generate Html 12
SaveChanges (1) 15
Render Body 0
Render Sidebar 18