lawnjelly / smoothing-addon

Fixed timestep interpolation gdscript addon for Godot Engine (version 3.2 or later)
MIT License
494 stars 28 forks source link

Jitter in 2D Window with KinematicBody2D #16

Open Playfulminds opened 2 years ago

Playfulminds commented 2 years ago

Thank you for putting this together. It may be that I have not set up correctly as I don't see the addon doing anything.

physics set to 60 fps Physics Jitter 0 to 0.5 --> no difference Use VSync On --> no difference Use VSync Composite -> huge difference for about 15 seconds then jitters, but less than without

I don't see that mesh connection like in 3D. So I just connected the player. Am I supposed to connect something else? global in --> no difference global out --> no difference

Did I set up something incorrectly? I don't see any differences with the addon on or off.

image

image

Calinou commented 2 years ago

Did I set up something incorrectly? I don't see any differences with the addon on or off.

To see the difference, try setting Physics Fps to a very low value such as 10 in the Project Settings. It should make the difference between having physics interpolation and not having it obvious.

Also, I recommend upgrading to Godot 3.4 as it offers delta smoothing when V-Sync is enabled. Since Godot 3.4, you can also enable an experimental option to sync frame delta after draw in the Project Settings.

Playfulminds commented 2 years ago

Delta Smoothing was checked. I tried enable sync as well no difference.

What is weird is there are spots on the screen that it goes smooth. Always the same area.

lawnjelly commented 2 years ago

If that is your node layout in your screenshot, then no it won't do anything. You need to place the visible nodes (sprites, whatever you use) as children of the Smoothing node, rather than children of the Player.

Alternatively if you are patient we should have this available in core soon in Godot 3.5 and it should be much easier to use.

Playfulminds commented 2 years ago

Ty for the response. Sorry for the noob questions. If I put the player as a child of Smoothing, all the in game speeds of the player are changed (accelerated) and it becomes a huge jitter. Is there a vid or noob instructions on how to use with 2D?

I am patient but I was wondering if this would fix the windowed jitters.

lawnjelly commented 2 years ago

The procedure in 2d is pretty much the same as in 3d: https://www.youtube.com/watch?v=lWhHBAcH4sM

The difficult thing you have to get your head around, is that you have to physically separate the physics representation of the player (kinematic body, rigid body etc), from the VISUAL representation (sprite etc).

ONLY the visual representation should go under the smoothing node, and this will follow the target (the Player kinematic body). Understanding this does depend on understanding some fundamentals of how godot does transforms and how the scene tree works.

Whether this will fix your jitters very much depends, in 2d especially there are a lot of sources of jitter, especially with pixel snapped games (which this will not fix entirely). If you are making a 2d pixel snapped game instead I would recommend checking out this explanation: https://github.com/lawnjelly/godot-snapping-demo

AbdoSarmini commented 1 year ago

Alternatively if you are patient we should have this available in core soon in Godot 3.5 and it should be much easier to use.

Hi. I see the option for physics interpolation in the physics settings in Godot 3.5, but it doesn't affect anything. Is this only for 3D or what?

Calinou commented 1 year ago

Is this only for 3D or what?

Yes, it's currently only for 3D. 2D physics interpolation is planned for Godot 3.6.