swipe camera movement wont stay between limitations

when i touch my screen (800x480)the camera disappears. im trying to limit the area where my camera can go.
i managed doing it with Clamp.

if (Input.touchCount > 0 && Input.GetTouch (0).phase == TouchPhase.Moved ) {
			Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;
			transform.Translate (touchDeltaPosition.x * Time.deltaTime * speed, touchDeltaPosition.y * Time.deltaTime * speed, 0);

			transform.position = new Vector3(	Mathf.Clamp(transform.position.x, minimumX, maximumX),	Mathf.Clamp(transform.position.y, minimumY, maximumY), transform.position.z);

old code :

using UnityEngine;
using System.Collections;

public class MoveCam : MonoBehaviour {


	public float speed = 3;




	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
		if (Input.touchCount > 0 && Input.GetTouch (0).phase == TouchPhase.Moved ) {
			Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;
			transform.Translate (touchDeltaPosition.x * Time.deltaTime * speed, touchDeltaPosition.y * Time.deltaTime * speed, 0);

			if (Camera.main.transform.position.x >= 1f )
			{
				Camera.main.transform.Translate (touchDeltaPosition.x =1f,0f,-10f);
			}
			if (Camera.main.transform.position.x <= -1f )
			{
				Camera.main.transform.Translate (touchDeltaPosition.x =-1f,0f,-10f);
			}
			if (Camera.main.transform.position.y >= 1f )
			{
				Camera.main.transform.Translate (touchDeltaPosition.y =1f,0f,-10f);;
			}
			if (Camera.main.transform.position.y <= -1f )
			{
				Camera.main.transform.Translate (touchDeltaPosition.y = -1f,0f,-10f);
			}

				
		
		}

	}
}

So I think where your problem is that you’re directly relating the touch input into the transform of your camera, if I’m reading this correctly. When you touch, it’s in screen positioning instead of world units.

So when you first press down and the touch phase is “Began” then record the position. Then convert that from screen units to world units. Camera.ScreenToWorldUnits I believe is the method, but check the unity script to make sure.

So when you move, convert the position to world units and then you can measure the world units instead of screen. Because right now, I believe when you swipe your sending your camera hundreds of world units out of position, which is why you’re getting the effect.

Let us know if you’re still having problems.