Hi, I have an environment for mobile devices that needs to allow players to scroll up and down - with an upper and lower limit.
The only script I have found allows for free movement - panning in every direction.
Could someone please help me out with this? Thanks a lot.
To clarify - I need a new script, or my current script, to allow players to touch move the camera along the Y axis only, but an upper and lower limit.
Current code:
Vector3 touchStart;
void Update()
{
if (Input.GetMouseButtonDown(0))
{
touchStart = Camera.main.ScreenToWorldPoint(Input.mousePosition);
}
if (Input.GetMouseButton(0))
{
Vector3 direction = touchStart - Camera.main.ScreenToWorldPoint(Input.mousePosition);
Camera.main.transform.position += direction;
}
}