Game Development Reference
In-Depth Information
Building trigger volumes
Imagine we want an invisible volume of space, and when the player stumbles into it,
it triggers a trap or a cutscene. This concept is used countlessly throughout modern
games (in fact, it's difficult to think of one in the last decade that doesn't use them
This effect is achieved in Bullet by simply disabling the contact responses for any giv-
en rigid body.
Continue from here using the Chapter6.2_TriggerVolumes project files.
Disabling contact response
There is no specific class required to build a trigger volume, but there is an essential
flag which we can apply to any object: CF_NO_CONTACT_RESPONSE . This flag dis-
ables all contact response, informing Bullet that it should not calculate any physical
response when other objects collide with the flagged object. This does not prevent it
from performing broad and narrow phase collision detection and informing us when
an overlap occurs, hence our CollisionEvent() and CollisionSeparation()
functions will still be called even for objects flagged in this way. The only difference is
that other objects will pass through it unhindered.
Here's a snippet of code from BasicDemo::CreateObjects() :
// create a trigger volume
m_pTrigger = new btCollisionObject();
// create a box for the trigger's shape
// set the trigger's position
btTransform triggerTrans;
Search WWH ::

Custom Search