Touch(): Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Created page with '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 [[co…')
 
 
Line 7: Line 7:
Touching can be disabled selectively by setting an appropriate [[collision group]], or altogether by [[SetSolid()|disabling QPhysics collisions]].
Touching can be disabled selectively by setting an appropriate [[collision group]], or altogether by [[SetSolid()|disabling QPhysics collisions]].


There is however no known call into entity code when deciding whether a touch should occur. The closest it gets is <code>CCollisionProperty::ShouldTouchTrigger()</code>, but as the name suggests that only applies to trigger touches. Other functions in game code deal only with collision groups; the guts of the system seem to be locked away in the engine.
Entity code is not normally called when determining if a touch should occur. However calls can be inserted in a few places:
 
* <code>CServerGameEnts::MarkEntitiesAsTouching()</code>
* <code>CBaseEntity::PhysicsMarkEntitiesAsTouching()</code>
 
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 <code>CBaseEntity</code> function can you guarantee success.


=== Triggers ===
=== Triggers ===

Latest revision as of 04:37, 2 June 2011

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 ).