Jittery 2D Player Movement

Godot Version

4.2.1

Question

Hi there, I’ve had issues with jittery player movement since I began with godot last week and have been trying to find a fix since.

I have tried altering Physics Ticks per Second to match the refresh rate of my monitor (60Hz) and have tried setting this much higher (240 ticks) as some people said this worked, but it did not.

I also tried splitting my code between the _process() and _physics_process() loops in countless ways but saw no change.

The problem is likely not the movement either since it occurs with multiple different movement techniques I have tried [incl. setting the position directly and using move_and_slide()], and the tutorials I followed seemed to have fluid movement unlike mine.

I replicated the official documentation guide and copied the source code directly, and the issue is still present as shown in video #1. This issue also happens with other projects with different movement including the one attached in video #2.

Video #1: https://youtu.be/BadADloWNH4
Video #2: https://www.youtube.com/watch?v=tiooQ3hjnJw

Could someone give me a hand with this please? Thanks very much.

If your player is moving using physics, you’ll need physics interpolation. It’s not builtin for 2D yet, but this addon should work fine: GitHub - lawnjelly/smoothing-addon at 4.x

If this is happening when you are moving your player manually (by accessing the transform in _process directly for example), the issue is most likely your movement code. (Hardware/OS or performance issues are possible too, but unlikely)

1 Like

If you are using position directly you can apply a vector lerp.

You can also lerp a target velocity to the character velocity before move and slide

1 Like

That seems very odd do you know if a GitHub issue exists?
I would think apply force and apply torque would be smooth enough. Character class don’t make sense to me since you adjust velocity and rotation move and slide does sort of magic.

1 Like

I’ve tried both solutions but nothing changed, I’m sure I implemented them correctly as I followed GitHub’s instructions for the plugin and saw movement speed changes when using lerp, but still had the same jittery / stuttery effect.

I don’t think the movement code is the issue since I’ve used code from mutiple different sources which worked fine for them and I’m certain it’s not a hardware problem since I’m able to run much more complex games with no problems.

Sorry for being difficult, I’m happy to give any more insight if it helps!

There could be rendering issues. I see the something similar on a camera 3d being lerped behind my character. But it’s not consistent.

The first video only seemed to show the issue mostly on rotation.

Second video is constant.

What are the differences?

1 Like

and maybe is it input lag… look here

1 Like

The first video directly changes the position where the second uses move_and_slide().

I’m now certain that it’s nothing to do with the movement code though, I tried using a project from the asset library when starting godot and still had the same issues:

It seems to go through phases of being okay to going absolutely nuts, i’ll try updating my drivers again because I’m sure the issue is with the rendering like you say.

Edit: Updating drivers did nothing which I’m slightly happy about because it saved me the embarrassment

2 Likes

Issue solved - Setting V-Sync to disabled or ‘mailbox’ (?) solves the issue, I’m not exactly sure why and I hope tearing doesn’t become an issue later on when I’m working on more complex projects.

Thanks very much for all of your help tho! Happy to give more info about it if you want to understand why it happened.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.