I don't know how to explain this, but it seems like, when making a character that moves at a certain speed, the game will sometimes (seemingly at random, but usually at about 15 second intervals) make the sprite "lunge" forward a few more pixels than it should.
So, to make sure this wasn't happening only in my project (that is already full to the brim with complex stuff that could be causing the problem) I decided to test this on a new project made from scratch. To my surprise, it still happens.
This is how the node tree looks (I apologize for the inappropriate node names, I was kinda angry when I made this):
And this is the script in the player character itself:
As you can see, I added a debug message that prints the amount of pixels the character moves in the x axis every second, to keep track of the bug.
Tiny subpixel differences are not a big deal. The ones that are particularly jarring are the ones where it leaps, like, 13 pixels more than it should (this test was done by moving to the right nonstop):
And it's also clearly visible in the test window itself (I can visibly see the character leaping forward, I can record a video if need be)
I tried exporting the project, and it still happens:
Searching the internet for information about this problem has led me to these two posts: (fluctuating physics update, from 2018) and (using hysteresis to repair physics jitter, from 2018). They describe a common problem where the number of physics frames is sometimes inconsistent with the number of render frames, and the second one introduces the "physics jitter fix" mechanic as a solution. So I decided to mess with the physics jitter fix variable to see what happens.
For testing purposes, I set it to zero. As to be expected, the jitters became more noticeable and more frequent. Funnily enough, however, they only really started being visually noticeable a few odd minutes into the test run.
I then changed it to 10, and while it seemed to work at first, as the test play went on, it started happening again. Big lunges, every 15 seconds or so, it just took longer to start happening. So on one hand, the jitter was a lot more noticeable, but on the other, the pixel per second count became more consistent.
I really don't know what I should do about this, and it's making me kind of sad. I just can't continue working on my game if the jitters won't go away.
Things I've tried so far:
- forcing FPS (tried 30 and 60) (no effect)
- disabling/enabling vsync (no effect)
- changing my monitor's refresh rate (tried 60Hz, no effect)
- closing every background program I could (no effect)
- restarting the computer a few times (no effect)
- setting the jitter fix really high (seems to delay the point at which it starts happening, but not the frequency with which it happens once it does)
- Lawnjelly's smoothing addon
Things I have not tried so far:
- running this on another computer (due to lack of an available computer)
- closing programs Windows normally does not allow me to close (due to not knowing how I'd even start doing that)
- it seems to start happening earlier if I need to tab out for some reason.
- my main project (i.e. not the one I'm using for this test) has a 16x16 character that moves roughly 133 pixels per second, with a jitter of 2 pixels every 15 seconds or so. If the resolution was higher, this wouldn't be a problem, but a 2 pixel jitter in a character that small is a bit too noticeable to ignore, and the players will also notice.
- Graphics card is AMD Radeon R7 260X.
- 8 GB DDR-3 RAM
- CPU is AMD FX-8350 eight-core (4 GHz)
- Running Godot 3.2.3
- Windows 7 64-bit
- I'm using an LG 22MK400H-B monitor (the internet says it's got a 75Hz refresh rate, not sure if that's accurate).
EDIT: I should probably clarify that the jitteriness I see when physicsjitterfix is off and the jitteriness I see when it is on are qualitatively different. When it is off, the game runs as normal most of the time, except, occasionally, the character starts "shaking" for a few seconds and then stops. It's more like the character is "trembling in place" if that makese sense, like the sprite keeps shifting back and forth at a very high speed.
When the physicsjitterfix is on, what the character does is occasionally (roughly every 15 seconds) "jump" a few pixels forward, and it doesn't return to the previous position, implying that the actual physics object moved forward in a jolt like that.
EDIT2: Lawnjelly's smoothing node does nothing for me because, at least judging from the video I watched, the problem it is designed to fix is entirely not the problem I'm facing right now. Despite my initial hesitation to use the node in my project (i.e. not the test project showcased here), I eventually caved and tried to use it. It did not solve my problem.
EDIT3: I can make the jitter happen on command by hitting PrintScreen. Could it be some kind of system call on my computer causing this problem? I mean, it might as well be, I have no idea at this point.
This entire situation is making me so, so sad. Like, all I wanted was to make a nice game in Godot, but here I am, having a problem that apparently nobody else has, and nobody knows how to solve. Everyone else having fun, making cool pixel art games and stuff, and here I am, trying to solve this darn problem so I can join the fun. Words can't express how much distress this problem has caused me in the last few days.