Lerp and camera problems

hi, i tryed to use the lerp for make my camera more smooth, but for some reason my character twitch a little every time it move, how do i can fixed and where?

Hi,
If you’re using small resolution, it’s a known issue.

my game use 800x620, can you recommend a better resolution?

This should be enough.
Can you share a screenshot or video of the twitches?

I suggest adding a “dead zone” where if the player (or whatever the camera is following) has not moved more than some threshold (i.e. 50 pixels) then don’t update the camera position.

well, the problem is that my obs is very laggy, i still have the video but it’s really hard to see the twich, but i can still post it if you want

that sounds good, can you teach me how to do that?

Create a new scene variable structure:
PlayerCamera.X
PlayerCamera.Y

Condition 1:
Always

Actions 1:
PlayerCamera.X = Player.X(“Center”) + SceneWindowWidth() / 2
PlayerCamera.Y = Player.Y(“Center”) + SceneWindowHeight() / 2

Condition 2:
Compare two numbers: Player.DistanceToPoint(PlayerCamera.X, PlayerCamera.Y) > Player.Width()

Actions 2:
Change X position of Camera: lerp(CameraX(), Variable(PlayerCamera.X), 1)
Change Y position of Camera: lerp(CameraY(), Variable(PlayerCamera.Y), 1)

This is untested and probably needs tweaking… but it’s the essential idea.

Hey, i was trying to use this format, but i can’t continue, you know what am doing wrong?

I just looked and it’s called “DistanceToPosition”… GDevelop has autocomplete so if I mistyped any others above you should be able to find something close.

I also see now that my reccommended logic is off… you should likely be checking the distance between the camera and the player camera… so something like this:
DistanceBetweenPositions(CameraX(), CameraY(), PlayerCamera.X, PlayerCamera.Y) > Player.Width()

Your obs?
If the twitching is hard to see, it’s probably the same issue as low-res games I mentioned earlier.
When a value is between two pixels, the rounding is not done properly, so it shows twitches.

well it’s only hard to see in the video, but you still can see,

i tried this and stills twiching, maybe because the code have some red marks for some reason