I think I figured it out. When creating the Collider, there’s a field for a Unity.Physics.Material which has a field for a Unity.Physics.Material.MaterialFlags, which is an enum. One of the options is EnableCollisionEvents. I’m not sure what the other two are.
Creating the Collider like this leads to CollisionEvents actually being generated.
var material = new Unity.Physics.Material
{
CustomTags = Unity.Physics.Material.Default.CustomTags,
Flags = Unity.Physics.Material.MaterialFlags.EnableCollisionEvents |
Unity.Physics.Material.MaterialFlags.EnableMassFactors |
Unity.Physics.Material.MaterialFlags.EnableSurfaceVelocity,
Friction = Unity.Physics.Material.Default.Friction,
FrictionCombinePolicy = Unity.Physics.Material.Default.FrictionCombinePolicy,
Restitution = Unity.Physics.Material.Default.Restitution,
RestitutionCombinePolicy = Unity.Physics.Material.Default.RestitutionCombinePolicy,
};
var boxCollider = Unity.Physics.BoxCollider.Create(
new BoxGeometry{
Orientation=quaternion.identity,
Size=new float3(0.25f,0.25f,0.25f)},
CollisionFilter.Default,
material
);
Then: var colliderComponent = new PhysicsCollider { Value = boxCollider };
EntityManager.AddComponentData<PhysicsCollider>(entity, colliderComponent);
and so on.
I haven’t tested whether it sees all of the CollisionEvents it should, but at least it sees some, and that’s a start.