This may be really simple but I couldn’t find the answer of how to do this on the forum. This is my code to attach a GameObject to the user’s finger. In my case the object is a second camera which you can move around, magnifying the scene. Only I would like to keep the camera within smaller bounds than the entire screen. So the question is: How do I stop the movement, say, 50px from the edge of the screen? Thanks.
function Update () {
for(touch in iPhoneInput.touches) {
if(touch.phase == iPhoneTouchPhase.Moved || touch.phase == iPhoneTouchPhase.Began) {
transform.position = Camera.main.ScreenToWorldPoint(new Vector3 (touch.position.x, touch.position.y, 50));
}
}
}