Do not use CameraInputController , but instead implement an InputProcessor and use this class in a call to Gdx.input.setInputProcessor .
For example:
public class MyGdxGame extends ApplicationAdapter implements InputProcessor {
And in the create method:
Gdx.input.setInputProcessor(this);
You will need to implement all the methods as shown in this link , with the exception of the touchDown and touchDragged , which require additional code:
private int dragX, dragY; @Override public boolean touchDown (int x, int y, int pointer, int button) { dragX = x; dragY = y; return true; } @Override public boolean touchDragged (int x, int y, int pointer) { float dX = (float)(x-dragX)/(float)Gdx.graphics.getWidth(); float dY = (float)(dragY-y)/(float)Gdx.graphics.getHeight(); dragX = x; dragY = y; cam.position.add(dX * 10f, dY * 10f, 0f); cam.update(); return true; }
Here, the values of dX and dY are the amount that the user dragged onto the screen in the range between -1f and +1f . For example. for dX value of 0.5f means that the user dragged half the screen size to the right. Note that these are delta values since the last method call. This method is likely to be called many times during a drag operation. For this, the values of dX and dY will be small values.
A call to cam.position.add(...) will actually move the camera, and a call to cam.update(); will recalculate the values needed for rendering. I used a 10f factor to convert the X and Y cameras. This means that if the user completely drags from the left edge to the right edge of the screen, the camera will move the total number of 10 units to the right. You can adjust the value as needed.
Note that this moves the camera to the XY plane. If you need to move, for example. XZ plane, you need to adjust the call cam.position.add(...) accordingly. In addition, this does not change the direction of the camera. If you want to move the camera while looking at the same place, you need to add cam.lookAt(0,0,0); just before cam.update(); .