1

I made a game using Libgdx where the character is being followed by the cameras, but the problem is that when my character moves the camera shakes.

velocity.add(0, gravity); velocity.scl(deltaTime); position.add(velocity.x, velocity.y); velocity.scl(1 / deltaTime); 

my character moves upward because the gravity is 9.8 and when the player touches the screen I set the velocity.x = 100 and velocity.y = -120to make it go downward and forward, that' s when the camera starts to shake.

camera.translate(100 * deltaTime, 0); 

I played with the values of camera shake but its either too fast or too slow and there's always a shake. What I wanted is a smooth camera with a delay effect when my character start to move.

1 Answer 1

1

You are not setting the camera to follow the player. The player and the camera moves the same direction but the camera is not depending on the player. Also try setting the cameras position instead of translating.

camera.position.x = player.position.x - gamewidth/2; camera.position.y = player.position.y - gameheight/2; camera.update(); 

For a delay effect you should move the camera towards the player position instead.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.