Collider Component: Triggers, Surface Properties, Keyframe Bodies, Concave Shapes, and Tag Propagation
Collider Component: Triggers, Surface Properties, and Keyframe Bodies
The Collider abstract base class is the foundation for all physics colliders in s&box (BoxCollider, CapsuleCollider, SphereCollider, HullCollider, ModelCollider).
Trigger Colliders
// Make a collider a trigger (no solid collision, only overlap detection)
collider.IsTrigger = true;
// Action Graph callbacks
collider.OnTriggerEnter = ( other ) => Log.Info( $"Entered: {other.GameObject.Name}" );
collider.OnTriggerExit = ( other ) => Log.Info( $"Exited: {other.GameObject.Name}" );
collider.OnObjectTriggerEnter = ( go ) => Log.Info( $"Object entered: {go.Name}" );
collider.OnObjectTriggerExit = ( go ) => Log.Info( $"Object exited: {go.Name}" );
// Query what's currently touching
foreach ( var touching in collider.Touching )
{
Log.Info( touching.GameObject.Name );
}Surface Properties
collider.Friction = 0.5f; // override friction (null = use surface default)
collider.Elasticity = 0.3f; // override bounciness (null = use surface default)
collider.RollingResistance = 0.1f; // override rolling resistance
collider.Surface = mySurface; // physics surface material
collider.SurfaceVelocity = Vector3.Forward * 100f; // conveyor belt effectSetting Friction, Elasticity, or RollingResistance to null reverts to the surface material's default values.
Static vs Keyframe Bodies
collider.Static = true; // PhysicsBodyType.Static — immovable, no physics
collider.Static = false; // PhysicsBodyType.Keyframed — moves with transform, pushes dynamic objectsNon-static colliders without a Rigidbody parent use a "keyframe body" — they follow the GameObject's transform and push dynamic objects out of the way. This is the correct way to move platforms and doors.
Concave Colliders
ModelCollider with a mesh shape is always IsConcave = true, which forces Static = true. Concave shapes cannot be dynamic in s&box's physics engine.Tags on Shapes
Collider shapes automatically inherit the GameObject's tags. When tags change on the GameObject, OnTagsUpdatedInternal() propagates them to all shapes. This is how trace tag filters work.
Rebuild
When a collider property changes (size, shape, etc.), Rebuild() is called to recreate the physics shapes. The [Resize] attribute on properties triggers this automatically via code generation:
[Property, Resize]
public Vector3 Scale { get; set; } // changing this auto-calls Rebuild()