+2 votes

I've seen various questions about this issue, but no conclusive answers that work for my case, which is about as simple as it's possible to get. I find it difficult to believe that this is an actual issue that cannot be solved, it's so fundamental to 2D games.

If I move a sprite in code in the _process(delta) function, using the delta to control speed, the result is unacceptably "stuttery" or "jerky". I've created as simple an example as I'm able to here, https://github.com/pgregory/godot3_tests/tree/master/stutter, which is simply a sprite, being moved across the screen.

If you run that, you'll see that rather than a smooth continuous movement, it stutters at irregular intervals.

This is currently a showstopper for a 2D game I'm working on, so any advice very gratefully received.

asked Mar 29, 2018 in Engine by pgregory (296 points)

I also encounter such issue. However, when I actually build the project to a standalone version, the stutter disappeared. Don't know why it stuttered when running in the editor though.

2 Answers

+1 vote

This happens in every game, even those not made with Godot, when they use V-sync, especially in editor/debug mode. This can be noticed in many games if you pay attention (and as such, isn't always a show stopper).

An exported game will be less likely to have the problem due to more optimizations being turned on.
You can also disable V-sync, which makes the problem disappear (at least on your example).
A downside of doing this is that you might experience screen tearing when the scene scrolls, because it will basically make your game run as fast as it can.

answered Mar 29, 2018 by Zylann (26,143 points)

I tried turning v-sync off, didn't make any difference to me. The effect is even more pronounced in the real game, which unfortunately I cannot share.

I'm not sure I agree that all games suffer with this. I've played many many many side-scrolling jump and run games, never seen it before, if I had it would have driven me insane.

Can you explain why having v-sync on should cause this? The demo is running at between 280 and 300 fps, so even with v-sync on, it should be fine, I can't see any logical reason for the movement to stutter the way it does while running at that frame rate.

The demo is running at between 280 and 300 fps, so even with v-sync on, it should be fine

You can't run a game at this speed with V-sync because V-sync caps framerate at 60 (or whatever your monitor refresh rate is), which means it is more likely to drop frames if there is any tiny delay (the cause can be very diverse on a PC).

I am not 100% sure what really causes the stutter, but I noticed it in many games I played (currently Factorio), so this is not a new problem and not specific to Godot.
I know that disabling V-sync makes it go away because I just tested it with your example.

It could be related to your driver, maybe?
There are issues opened on Github about this problem:
https://github.com/godotengine/godot/issues/2043
https://github.com/godotengine/godot/issues/10388

Thats is not completely true, yes games made in other engine might have some stuttering but its not as noticeable and doesn't happen this frequently, I've experienced the same problems with Godot but I can't say the same of Unity and Game Maker Studio, in those engines simple projects like this one look very smooth.

0 votes

Hello @pgregory,

Did you conclude something from this?

I started a similar discussion here:

https://godotdevelopers.org/forum/discussion/comment/25017/#Comment_25017

I would appreciate if you could share what actions you took.

Did you fix it or did you stop using Godot... What happens?

answered Sep 8, 2018 by leonardon (14 points)

No, haven't found a solution yet, in fact it's getting worse. I continue to try, but at the same time am porting my game to Unity to hedge my bets.

Paul

It very well may not help you if you have to stay in v2, but this was supposed to be mitigated in the master branch. Would be interesting to see if you have the same issue. I guess you could even try recreating your prototype in the 3.1 alpha. Check out the bottom of the first link that Zylann posted for info.

I've download the "stutter" project and tried it in 3.1 beta - same problem. It stutters with v-sync on and stutters differently with v-sync off. I'm having a similar problem with a 2D pixel based game when moving the camera, that's how I ended up here.

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.