[0.51] Unable to change CollisionFilter

This section of the Physics docs shows how to modify a CollisionFilter at runtime:
Core components | Unity Physics | 0.51.1-preview.21 see "
Modifying PhysicsCollider".

I have two jobs, one that sets a new CollisionFilter and one that plays back the result in the console:

Entities
           .WithAll<UnitNeedsSetup>()
           .ForEach((Entity entity, int entityInQueryIndex, ref PhysicsCollider collider, in Unit unit) =>
       {

           collider.Value.Value.Filter = new CollisionFilter()
           {
               BelongsTo = unit.team == 0 ? 1u << 0 : 1u << 10,
               CollidesWith = ~0u
           };;
           Debug.Log("[assignment] team " + unit.team + " assigned " + collider.Value.Value.Filter.BelongsTo) ;
       }).Run();
    
       Entities
           .WithAll<UnitNeedsSetup>()
           .ForEach((Entity entity, int entityInQueryIndex, in PhysicsCollider collider, in Unit unit) =>
           {
               Debug.Log("[playback] team " + unit.team + " assigned " + collider.Value.Value.Filter.BelongsTo) ;

           }).Run();

Results in the output:

[assignment] team 0 assigned 1
[playback] team 1 assigned 1
[playback] team 0 assigned 1```

Why is the collision filter not remaining set? Also, if I set:
```BelongsTo = 1u << 10;```
It seems to stick.

SOLVED EDIT: This seems to be because my colliders are not unique. Checking the "Force Unique" checkbox in the Physics Shape component does not work for runtime: https://discussions.unity.com/t/780547

I need to generate a brand new collider on the component when it is instantiated, something like:

var newCollider = new PhysicsCollider
{Value = CapsuleCollider.Create(capsuleGeo, spawner.team == 0 ? collisionFilterTeamOne : collisionFilterTeamTwo)};

commandBuffer.SetComponent(entityInQueryIndex, instance, newCollider);

Hey @staringatlights

I had a similar issue. The problem is that you changing CollisionFilter which is the part of BlobAsset, thus, when you change it to one instance, you actually change it to any that uses that BlobAsset.
That is why the first element has the value of the last changed one.

That works for me now, so I don’t have any solution yet