More Accurate Trigger Events

To trigger an event in a level, it’s natural to throw in some kind of Volume: Trigger or TriggerVolume for a unique event, maybe something extending PhysicsVolume for a forceful or destructive event, etc. Then all you have to do is script the Touch() event or use Kismet to control what you want to do.

The problem with this, however, is that Volumes have an inaccurate “touch field”. The inaccuracy depends on the volume size and the actor being targeted, but it’s usually around 8 Unreal Units off. For most applications this is just fine (especially for first-person shooters since the camera doesn’t even show the player touching the trigger), but in my case it wasn’t good enough. I had a rigid body that was supposed to explode upon hitting a certain kind of volume, and it wouldn’t be nice at all to the player if the ball exploded when it was still 8UU away.

So I turned to rigid body collisions instead. Rigid body collisions are much more accurate because they rely on underlying physics simulations rather than simple traces and touch events. To make this work we need to base the code in an actor with rigid body physics enabled; instead of letting the actor touch the volume, we let the volume touch the actor like so:

event RigidBodyCollision(PrimitiveComponent HitComponent, PrimitiveComponent OtherComponent,
const out CollisionImpactData RigidCollisionData, int ContactIndex)
if(OtherComponent != none) {
if(MyVolume(OtherComponent.Owner) != none)

Frame-by-frame replay testing shows that this triggers the explosion exactly when the actor touches the volume. Lesson learned: when you need accuracy, always turn to rigid body physics.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s