title: LibGDX camera following player with TiledMap?
body: <p>I am attempting to set the camera to focus on the player in the center, as it goes over a TiledMap fixed in place. I am using this rendering code for the camera:</p>
  
  <pre><code>OverworldWorld world;
  Player player;
  OrthographicCamera cam;
  SpriteBatch batch;
  TiledMap map;
  TileAtlas tileAtlas;
  TileMapRenderer tmr;
  
  public Renderer(OverworldWorld world){
      this.world = world;
  
      world.setRenderer(this);
  
      width = Gdx.graphics.getWidth();
      height = Gdx.graphics.getHeight();
  
      new TiledLoader();
      map = TiledLoader.createMap(Gdx.files.internal("maps/island.tmx"));
      tileAtlas = new TileAtlas(map, Gdx.files.internal("maps/"));
      tmr = new TileMapRenderer(map, tileAtlas, 16, 16);
  
      cam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
      cam.setToOrtho(false, width, height);
      cam.position.set(0, 0, 0);
      cam.update();
  
      batch = new SpriteBatch();
      batch.setProjectionMatrix(cam.projection);
  
      sr = new ShapeRenderer();
  
  
  }
  
  public void render(){
      Gdx.gl.glClearColor(0, 0, 0, 1);
      Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
  
      player = world.getPlayer();
  
      cam.position.set(player.getPosition().x, player.getPosition().y, 0);
      cam.update();
  
      tmr.getProjectionMatrix().set(cam.combined);
  
      Vector3 tmp = new Vector3();
      tmp.set(0, 0, 0);
      cam.unproject(tmp);
      tmr.render((int) tmp.x, (int) tmp.y, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
  </code></pre>
  
  <p>The result is that the player is locked to the bottom left corner of the map, and moving the player moves the camera over the map. The movement is pretty basic:</p>
  
  <pre><code>player = world.getPlayer();
      switch(keycode){
      case Keys.W:
          player.getVelocity().y = 1;
          player.direction = "up";
          break;
  </code></pre>
  
  <p>and updating the player position uses this (this is with version 0.9.8):</p>
  
  <pre><code>position.add(velocity.tmp().mul(Gdx.graphics.getDeltaTime() * speed));
  </code></pre>
  
  <p>What is causing this issue, and how can it be fixed?</p>