Race against screen

im wondering how would someone go about making a game where the screen constantly move lets say to the right whether your characters moves and not and where if ur character is standing on between a hard object and the left edge of the screen ur character would die or something.

i think i know how i would be able to detect the edge of the screen but from there im not sure…

If your dealing with a perspective camera, check my answer here. A dirtier but maybe faster way would be to have 4 colliders on each side of the camera’s frustrum to detect collisions (you’ll need them to have a kinematic full constrained rigidbody).

If it’s orthographic, you can know the pos of each sides with the orthographic size and the aspect ratio (the next pos are relative to the cam) : right= (size * aspect, 0) left = -right, top = (0, size) bottom = -top.