Efficient "constant screen size" colliders

Hey everyone, I am doing a 3d modeling application. I need constant screen size colliders for vertices and edges, so they are clickable from every zoom level. The current implementation is to updates all of the colliders every frame that the camera moves, but that causes physics world rebuilds which is slow. Is there any simple solution that I am missing? The only thing I can come up with is to throttle the number of colliders updated every frame, but that would not be the simplest or best feeling solution.

Not sure what you’re doing, but I am achieving constant screen size by just scaling transforms based on camera orthographic size. I do it before the transform system runs (because it seemed like a sensible place to do it) and I just let the physics system pick up the change in scale whenever it runs.

I haven’t profiled so no idea how performant it is, but it appears to work at least.

You can uniformly scale colliders efficiently and without having to recreate the collider by using the entity’s LocalTransform.Scale property.

I assume that uniform scaling would be sufficient for your use case.

1 Like