I am making a 2D game using Unity, and in the game you see the world from the side like in the first Super Mario games. But instead of moving the camera by walking, I want to move the camera by dragging with the mouse cursor. So basically move the cursor to the right of the screen click and hold and then move the cursor to the middle should move the camera to the right, and then vice versa to move left (So the camera is only moved on the x-axis). The game also has a feature to drag and drop objects and I used this tutorial for that: https://youtu.be/HfqRKy5oFDQ
And I am now trying to implement this by adding to the code from that tutorial. I have this code:
private IEnumerator DragCameraUpdate()
{
while (mouseClick.ReadValue<float>() != 0)
{
print("Mouse " + Time.deltaTime);
yield return null;
}
}
So this loop works just as expected it loops through when the mouse is pressed and stopps when its not clicked anymore. How can I now make the camera follow the cursor drag, but only on the x-axis?
Thanks in advance?