Revision Difference
GM:ShouldCollide#553255
<function name="ShouldCollide" parent="GM" type="hook">
<ishook>yes</ishook>⤶
<description>
Called to decide whether a pair of entities should collide with each other. This is only called if <page>Entity:SetCustomCollisionCheck</page> was used on one or both entities.
Where applicable, consider using <page>constraint.NoCollide</page> or a [logic_collision_pair](https://developer.valvesoftware.com/wiki/Logic_collision_pair) entity instead - they are considerably easier to use and may be more appropriate in some situations.
<warning>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 <page>Entity:CollisionRulesChanged</page> on that entity immediately - **not in this hook.**</warning>
<bug issue="642">This hook can cause all physics to break under certain conditions.</bug>
</description>
<realm>Shared</realm>
<predicted>Yes</predicted>
<args>
<arg name="ent1" type="Entity">The first entity in the collision poll.</arg>
<arg name="ent2" type="Entity">The second entity in the collision poll.</arg>
</args>
<rets>
<ret name="" type="boolean">Whether the entities should collide.</ret>
</rets>
</function>
<example>
<code>
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
end )
</code>
</example>