TopDown local multiplayer camera edges collision?


I’m working on a local multiplayer top down shooter. Currently I have the camera zoom out as the players move further away from each other, what I want is the players to collide with edges of the screen but can’t figure out how. So let’s say player one is on the center of the screen and player 2 is walking towards the edge of the camera, the camera would follow player 2 until player 1 is on the edge and then stop player 2 from walking any further away. Hope you get what I mean. I have searched everywhere and couldn’t find any answers, tried with colliders attached to player 1 or camera but that would just drag other players when they get to the edge :frowning: Please help

@pbiesek92 I’m wondering if you could use Camera.WorldToViewportPoint(Vector3) for this problem?
This returns a vector where the x and y components represent the screen position relative to the camera rendering the screen. If this returns values really close to 1 or 0, you’d know the players are close to the edge of the screen (and therefore you could artificially stop them from moving farther in that direction).