- Home /
Question by
karlanton98 · Aug 22, 2019 at 11:05 AM ·
camera2dcamera movement
Pan the camera in 2d while mouse being dragged down at any orthographic size?
Currently I'm able to pan the camera around the scene in 2D while holding down a mouse button. However, I'm also zooming in and out and which makes the drag speed slow when the camera is far away so to fix this i tried just taking the orthographic size to the power of 2 and use that as the camera speed which didn't work perfectly, do you have any better ideas?
cameraMoveSpeed = Mathf.Pow(camera.orthographicSize, 2);
newCameraPos.x += ((Input.GetAxis("Mouse X") * -1) * Time.deltaTime * cameraMoveSpeed);
newCameraPos.y += ((Input.GetAxis("Mouse Y") * -1) * Time.deltaTime * cameraMoveSpeed);
camera.transform.position = newCameraPos;
Comment
Your answer
Follow this Question
Related Questions
2d camera movement with Lerp problem 0 Answers
Why is 2d camera not smooth at 30 FPS 0 Answers
2D camera rotating relatively to game object speed 0 Answers
Camera/can't turn on X 1 Answer
camera follow problem-unity 4.3 2d 1 Answer