- Home /
Question by
kakasss · Jun 17, 2021 at 08:14 PM ·
2dcamera-movementpanningmobilephone
2d camera panning
Hey, I'm trying to panning my camera like mobile panning, here is my current code.
Vector3 move;
private void CameraMovement1()
{
if (Input.GetMouseButtonDown(0))
{
dragOrigin = Input.mousePosition;
return;
}
if (!Input.GetMouseButton(0))
return;
Vector3 pos = Camera.main.ScreenToViewportPoint(Input.mousePosition - dragOrigin);
move = new Vector3(0, pos.y * dragspeed, 0);
transform.Translate(-move * Time.deltaTime, Space.World);
}
In a mobile phone when you scrool Its keep going until you touch somewhere or scrolling speed decreases. But in my code if you want to scroll you have to keep scrolling. So, my question is how can i make mobile phone scrolling? Any idea, suggestion or something will be helpful.
Comment
Answer by kakasss · Jun 19, 2021 at 01:06 AM
well, I cant solve the problem but I found different way to make. I make a canves with world space and change location to camera position. And make in canvas a simple scroll react. It's kinda work now. if anyone wondering how to make scroll react, here is simple explation, https://www.youtube.com/watch?v=rAqyi85IAJ0