Issue with 2d camera when following player

Godot Version

4.3.0.0

Question

I’m having a problem with the 2d camera when following the player. When the player is in a room moving around, but they are pushed up against the camera limits, so that the camera is not following them, everything looks fine. But as the player moves to the center of the room, whenever they reach the point where the camera starts moving to follow them, there is a noticeable ‘hiccup’ at that moment.

As the player continues to move, everything looks fine, until the player reaches another point where the camera stops following the player because the player has reached the camera limits again. At that point where the camera stops following the player, there is another ‘hiccup’. I don’t know exactly what this hiccup is; it’s a graphical twitch you can see with the player.

I can go back and forth, and it will do this graphical twitch each time the camera starts or stops following the player because of camera limits (it doesn’t twitch if the camera stops simply because the player stopped moving).

Another weird thing is that if I push the player up against a wall, or jump up and hit his head on the ceiling, this graphical twitch stops. I can then walk wherever, and it will not happen. For some reason, the collision between the player and the floor does not fix the issue, it is only walls or ceiling.

I had a very similar problem to this with my last game. When the player moved within the camera, but the camera wasn’t following the player, everything looked fine. But as soon as the player moved to a point where the camera would need to follow the player, the player would look very shaky as the camera followed him. In this case, it was not just a one-time twitch, it was constant shakiness (of the player) as the camera followed the player. However, if I pushed the player up against a wall or hit the ceiling, the camera could follow the player anywhere after that and it looked normal. Since that game was just a demo, what I ended up doing was starting the game with the player inside the wall a little bit. When the game would start, it would immediately push the player out of the wall, and then you would never see any shakiness when the camera followed him, because it sorted out whatever the issue was. But that is not really a good solution.

Thoughts? Any ideas on solving this are very much appreciated.

Edit: I was a bit off in my description. It does not happen precisely at the moment the camera starts following the player, it happens a little bit after the camera has started following the player.

I noticed that if I disable “Snap 2D Transform to Pixel” that the problem goes away. If I turn on “Snap 2D Vertices to Pixel” I get the same issue, but more pronounced.

Have you got physics/common/physics_interpolation enabled in project settings?

It was disabled and I tried enabling it, though unfortunately it made it quite a bit worse.

I didn’t think this would matter, but out of desperation I redid my sprite sheet making it 128x32 instead of 96x24 and the problem seems to be gone. I had remembered reading something a long time ago about making the graphics files power of 2.