Setting size of a box collider on instances of a DOTS prefab independently at runtime using Unity Physics

So in our project we instantiate DOTS prefabs containing a box collider with a (1, 1, 1) size. However, each of our instance can have an arbitrary size.

In the Physics samples, from what I understand, it modifies the BlobAsset. Since we always instantiate the same prefab, it would then modify the common BlobAsset and all of my instances would have the same collider size.

In a comment in the samples, it says:

if you want to modify prefab instances independently, you need to create unique BlobAssets at run-time and dispose them when you are done

I guess that’s how I need to do it. I know how to create a basic BlobAsset from reading the documentation, but I’m not too sure how I would proceed to copy an existing BlobAsset and then set it in the PhysicsCollider component. How could I achieve that?

1 Like

Ok so I found ways to do this, either add the ForceUniqueColliderAuthoring component at bake, or call PhysicsCollider.MakeUnique() at runtime. Then do the same as what’s happening in the sample scene for modifying collider at runtime.