Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

godot 4 low process priority causes stutter #49

Open
just-wasted opened this issue Nov 7, 2023 · 5 comments
Open

godot 4 low process priority causes stutter #49

just-wasted opened this issue Nov 7, 2023 · 5 comments

Comments

@just-wasted
Copy link

just-wasted commented Nov 7, 2023

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)

@lawnjelly
Copy link
Owner

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.

@just-wasted
Copy link
Author

just-wasted commented Nov 9, 2023

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.

@lawnjelly
Copy link
Owner

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

@just-wasted
Copy link
Author

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.

@lawnjelly
Copy link
Owner

lawnjelly commented May 4, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants