smoothing-addon icon indicating copy to clipboard operation
smoothing-addon copied to clipboard

godot 4 low process priority causes stutter

Open just-wasted opened this issue 1 year ago • 5 comments

Hey lawnjelly, thanks for this great addon! Had some issues in 4.1.3 with the plugin in 2d: The smoothed sprite was several frames behind (input lag) and had stutters, which became really noticeable when i attached a ui label as child to the smoothed sprite. All this problems went away when setting set_process_priority(100) to 0 in smoothing_2d.gd's _ready() function.

Whats the reasoning for setting the process priority that low? Are there issues i could run into leaving it at 0? (edit: nvm, found the readme section about it)

just-wasted avatar Nov 07 '23 03:11 just-wasted

Yes essentially the problem is this:

  • You want the target to move before the smoothing node gets the target position (on each tick).
  • By default, nodes process in scene tree order, so if you had a smoothing node above the target node, it would get the position of the target before it had moved, and you would get this extra tick of lag.
  • To fix this, we bump up the process_priority of smoothing nodes to 100. This makes them process after the target (unless you have changed the process_priority of a target to over 100.

Note that process priority is inverse compared to what you might expect. Lower values execute before higher values.

lawnjelly avatar Nov 07 '23 06:11 lawnjelly

thanks for the response. i had not touched process priority on the nodes involved or any other in this project. scene tree of nodes involved is grafik

the smoothing node being below the phys rep i think i shouldn't run into issues with setting the process priority to 0 in the smoothing script.

just-wasted avatar Nov 09 '23 16:11 just-wasted

If you are still having a problem, please include a minimum reproduction project and I can take a look. :+1:

lawnjelly avatar Nov 10 '23 05:11 lawnjelly

smoothing_stuff.zip

here is reproduction project. F5 to run it, LMB to give move commands. If you give move commands in opposite directions you should notice that the position on screen of the sprite and the label changes, which shouldn't be the case. If you change process priority from 100 to 0 in smoothing_2d.gd the issue goes away.

just-wasted avatar Nov 11 '23 17:11 just-wasted

Sorry it took a while to look at this, I must have missed the reply (being away from home).

On latest master, first thing I did was lower the physics tick rate to 10 ticks per second to see what is happening (project_settings/physics/common/physics_ticks_per_second).

With latest master (4.x) built from source I'm not seeing any different between the sprite and label. So this could have been a bug in 4.x that has been since fixed (rather than the addon).

What I am seeing is that sometimes there is some vibration occurring in the CharacterBody2D (even without using smoothing addon). This may be down to the script or a bug in navigation system or something like that.

(Yes, it looks like it's probably overshooting the navigation destination in your script.)

Also it works the same using core physics interpolaiton which is now available in 4.x.

lawnjelly avatar May 04 '24 14:05 lawnjelly