Skip to content

Collisions & Triggers

Every body has a Collision Profile with a Layer and a Mask.

  • Layer is the category this body belongs to.
  • Mask is the categories this body collides against.

Two bodies collide if either one’s mask includes the other’s layer. The built-in layers are Static, Dynamic, and Channel 0 through Channel 13 for your own gameplay categories. For example, put bullets on a channel and give them a mask of only the layers they should hit, so they pass through everything else.

By default a body’s Layer is Dynamic and its Mask is Static + Dynamic, so ordinary bodies collide with the world and each other.

By default a collider is solid. Bodies bounce off it, and you receive contact events.

Turn on a collider’s Is Trigger flag and it stops being solid. Bodies pass through it, but you receive overlap events. Use triggers for pickups, checkpoints, and damage volumes. The rigid body’s Is Sensor flag does the same thing at the whole-body level.

A rigid body publishes its contacts and overlaps as delegates on SRigidBodyComponent. Contacts are solid collisions. Overlaps are triggers, which report but produce no physical response.

The delegates are the same objects in both languages, only the way you attach differs: C++ adds a lambda, C# binds a method.

SRigidBodyComponent& Body = Context.Get<SRigidBodyComponent>(Entity);
Body.OnContactBegin.AddLambda([](const SCollisionEvent& Event)
{
LOG_INFO("hit {} at {} m/s", (uint32)Event.Other, Event.ImpactSpeed);
});
Body.OnOverlapBegin.AddLambda([](const SCollisionEvent& Event)
{
LOG_INFO("entered trigger of {}", (uint32)Event.Other);
});

AddLambda returns an FDelegateHandle. Nothing unbinds it for you, so keep the handle and remove the binding when the owner goes away.

The full set is OnContactBegin / OnContactEnd and OnOverlapBegin / OnOverlapEnd, each carrying an SCollisionEvent, plus the payload-free OnWake / OnSleep.

SCollisionEvent is oriented from your entity’s point of view, in both languages.

FieldMeaning
EntityYour entity
OtherThe other entity
PointWorld-space contact point (FVector3)
NormalContact normal, pointing away from you (FVector3)
Velocity / OtherVelocityLinear velocities at contact (m/s)
RelativeVelocityOther minus self (FVector3)
ImpactSpeedSpeed along the normal (m/s)
bIsTriggertrue if the other side was a trigger or sensor
BodyID / OtherBodyIDThe Jolt body ids