Move Camera- Edge Of The Screen

Hello everyone, I have a question. My game is 2.5D platfrom game. When player presses “a” & “d” keys, my character moves to right or left it’s alright. But I want to move my camera too, but I don’t want camera to move at the same time with the character. When character gets closer to the right border of the screen, camera will move right. I want that. Like that:

if(Vector3.Distance(character.position,rightBorder)<5)
{
CameraMove();
}

So how can I detect the borders ?

You need a collider on the 2 dimensions of your game (use layers so it doesn’t screw with the rest ), the use ViewportToRay, with (0, 0) and (1, 0) to get the world pos of each edge. Or the other way around …