Touch()

From Valve Developer Community
Revision as of 03:37, 2 June 2011 by TomEdwards (talk | contribs) (Controlling touches)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Entities will touch each other when their bounding boxes collide or intersect. Touching is a Quake-era concept unrelated to VPhysics, and happens regardless of collision models or hitboxes.

Touching occurs on the server only and results in calls to the Touch(CBaseEntity* pOther) functions of both entities involved.

Controlling touches

Touching can be disabled selectively by setting an appropriate collision group, or altogether by disabling QPhysics collisions.

Entity code is not normally called when determining if a touch should occur. However calls can be inserted in a few places:

  • CServerGameEnts::MarkEntitiesAsTouching()
  • CBaseEntity::PhysicsMarkEntitiesAsTouching()

Be aware when editing your own entity that you cannot reliably prevent other entities from creating their own touches (it all depends on who moved first). Only by altering the CBaseEntity function can you guarantee success.

Triggers

To make an entity touch others without colliding with them, call AddSolidFlags( FSOLID_NOT_SOLID | FSOLID_TRIGGER ).