0 votes

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):

node tree

And this is the script in the player character itself:

player character script

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):

sudden jump forward

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:

still happens even with the project exported

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)

Other information:
- 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.

System information:
- 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.

Godot version (3.2.3)
in Engine by (12 points)
edited by

is it acceptable to bump a question?

1 Answer

+1 vote

Try installing, enabling and configuring lawnjelly's smoothing-addon on your KinematicBody or RigidBody.

by (10,952 points)

Thanks for the tip. I'll try that real quick and get back to you with the results.

so, it turns out this works on the test project, but given that I need to pull the sprite out of the main physics object, that makes it not very good for my project, since my main character is composed of several sprites and they may be moved far apart from one another at certain points, so I don't tihnk that will work for me.

EDIT: I was too hasty to say that it worked on the test project, actually. Messing around with the test project today, I discovered the problem is still there, but for some reason it wasn't showing itself last time I tried.

Turns out this idea works on the test project, but for some reason does not work on my actual project. I have to wonder if there's something wrong with it. Is there any way I can send the source project for someone to check it out? Cuz I don't know what to do anymore.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.