- Home /
dragging camera with mouse results in camera jumping.,
I'm trying to move the camera with the mouse but when the mouse starts moving the camera starts to jump between to positions, these positions still somewhat follow the mouse movement.
if(Input.GetMouseButtonDown(1))
{
dragOrigin = GetComponent<Camera>().ScreenToWorldPoint(Input.mousePosition);
}
if(Input.GetMouseButton(1))
{
dragNew = GetComponent<Camera>().ScreenToWorldPoint(Input.mousePosition);
transform.Translate(dragOrigin.x - dragNew.x, dragOrigin.y - dragNew.y, 0);
dragOrigin = dragNew;
}
This is within Update(), dragNew and dragOrigin are Vector3.
What could cause such an odd behaviour?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612175446im_/https://answers.unity.com/themes/thub/images/avi.jpg)