I want to grab my terrain and move the camera with my mouse, this was fairly simple to do using speed:
newPosition = transform.position; //Set in Start
//...
// In update
newPosition -= new Vector3(Input.GetAxis("Mouse X") * cameraDragSpeed, 0, Input.GetAxis("Mouse Y") * cameraDragSpeed);
transform.position = Vector3.Lerp(transform.position, newPosition, GameManager.Instance.GetNormalizedTimescale() * acceleration);
But I dont want to use speed, I want to use the difference between the drag origin (or the last drag position) and the new drag position.
I got some code running that oddly work “kind of” well, but has periods where it starts acting rly strangly, like the camera will keep panning while I hold down my button, even tho im not moving the mouse. But it happens very randomly. Or sometimes the drag speed is really responsive but other times its like im dragging in mud.
// In update
// Drag movement
if (Input.GetMouseButtonDown(1))
{
cameraMovementDragOrigin = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));
}
else if (Input.GetMouseButton(1))
{
var diff = cameraMovementDragOrigin - new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));
newPosition += new Vector3(diff.x, 0, diff.y);
transform.position = newPosition;
return;
}
Can someone spot what im doing wrong?