Garry's Mod Wiki

GM:ShouldCollide

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 or a logic_collision_pair entity instead - they are considerably easier to use and may be more appropriate in some situations.

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

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 )

Special Pages


Wikis

?

Render Time: 21ms

DB GetPage 2
Generate Html 6
SaveChanges (1) 5
Render Body 0
Render Sidebar 5