# Camera Movement and Zooming limit,

Did anyone knows of how to limit the Z axis? I use this as a camera control And the thing I want to know is how can I limit the zoom of Z axis? Like…! If Z Axiz has “lower than -125” And the thing I want to do is stop zooming there! Did anyone know? Thank you!

```   using UnityEngine;

public class OrbitalKey : MonoBehaviour
{
public int Speed = 2;

void Update()
{
float xAxisValue = Input.GetAxis("Horizontal") / Speed;
float zAxisValue = Input.GetAxis("Vertical") * Speed;

transform.position = new Vector3(transform.position.x + xAxisValue, transform.position.y, transform.position.z + zAxisValue);
}
}
`
````

public class CameraScript : MonoBehaviour {

`````` 	public int Speed = 2;
public float zoomlimit = -125;

void Update()
{
float xAxisValue = Input.GetAxis("Horizontal") / Speed;
float zAxisValue = Input.GetAxis("Vertical") * Speed;

float zoomDistance =  transform.position.z + zAxisValue;
if (zoomDistance < zoomlimit ) {
transform.position = new Vector3 (transform.position.x + xAxisValue, transform.position.y, zoomDistance);
}
}
}
``````

@Totoh899 Reffer this code

Thank you so much! @vatsav-gundigara But one thing tho! The script you wrote is not 100% correct… Lemme fix that a little

```using UnityEngine;

public class CameraScript : MonoBehaviour {

public int Speed = 2;
public float zoomlimit = -125;
void Update()
{
float xAxisValue = Input.GetAxis("Horizontal") / Speed;
float zAxisValue = Input.GetAxis("Vertical") * Speed;

float zoomDistance =  transform.position.z + zAxisValue;
if (zoomDistance > zoomlimit ) {
transform.position = new Vector3 (transform.position.x + xAxisValue, transform.position.y, zoomDistance);
}
}
}
`

It should be from "<" to ">" But hey! Thank you so much for your help! Now I'm learning more from coding!
````