Trying to stop the camera at the edge of the world

So I am making a simple 2d sandbox game. It is generated with random chunks of 25 tiles wide and I can’t seem to figure out how to stop the camera at the beginning of the first chunk and the end of the last chunk (whichever number of chunks in the world.) So if I could get some help that would be great. Thanks :slight_smile:

If you are moving the camera using transform.position then you could add a check to make sure the camera stays within the bounds.

    public float minPosition;
    public float maxPosition;

    public float moveSpeed;

    public void Move()
    {
        Vector3 direction /* get direction from input */;

        var newPosition = this.transform.position;

        newPosition += direction * moveSpeed;

        if (newPosition.x < minPosition)
        {
            newPosition.x = minPosition;
        }
        else if (newPosition.x > maxPosition)
        {
            newPosition.x = maxPosition;
        }

        this.transform.position = newPosition;
    }

you can repeat the if statements for the y axis as well if needed.