LibGDX camera smooth translation
camera, java, libgdx, opengl
Solution
I think that you don't want linear interpolation, but something like this (not tested, and the vector operations should be considered pseudo-code at best):
//Change speed to your need
final float speed=0.1f,ispeed=1.0f-speed;
//The result is roughly: old_position*0.9 + target * 0.1
cameraPosition.scale(ispeed);
target.scale(speed);
cameraPosition.add(target);
camera.position.set(cameraPosition);
Problem
How can I lerp (linear interpolate) the camera of top view game which has follow on player so it doesn't tremble as it gets close to the target. This is the code I use for camera translation: ``` //Creating a vector 3 which represents the target location (my player) Vector3 target = new Vector3( (float)player.getPosition().x*map.getTileWidth()+(float)map.getTileWidth()/2, (float)player.getPosition().y*map.getTileHeight()+(float)map.getTileHeight()/2, 0); //Creating vector 3 which gets camera position Vector3 cameraPosition = camera.position; //Interpolating (lerping) vector cameraPosition.lerp(target, 0.1f); //Updating camera and setting it for batch camera.position.set(cameraPosition); camera.update(); batch.setProjectionMatrix(camera.combined); ``` I think I did this right but the alpha value might be too small, yet again if i make it bigger then camera moves too fast and other issues appear. Can i make the trembling stop with this alpha value (in my example alpha is 0.1f)?