Collider sticks to window border

I want to make a physics simulation where the ground and walls are always at the browser window edges. how do I “attach” the colliders to the browser window? (should move and scale with resize, work on mobile.)

Is it possible to piggyback on the 2D UI Elements (as they already offer this functionality in 2D)?


You have to calc it somehow, I guess.
Probably raycast from screen corners?

My solution was to just move some boxes with the window on resize so my question is how to do that. Thx.

Okay, so, firstly you need an event listener for this event.

window.addEventListener("resize", event => {this.recreate(event)});

Then you need to calculate your blocks positions using screenToWorld method of Camera.
Afterwards, just move your wall there.