Camera Bound

Hello guys , i want to keep my camera in a terrain…terrain would be the boundary for my camera…

im looking through y. it’s a 2Dimentional…How can i achieve this ?

pass the terrain width and height into a script you write for the main camera - and simply put bounds on the x and z axis

for example say you have the center of your terrain at 0,0 and its 500x500

if(transform.position.x > 250){
transform.position.x = 250;
}
if(transform.position.x < -250){
transform.position.x = -250;
}

and so on

the camera is perspective man… i need viewport coordinates.