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

Jittery camera movement #173

Closed
HappyHeads opened this issue Jan 16, 2024 · 5 comments · Fixed by #179
Closed

Jittery camera movement #173

HappyHeads opened this issue Jan 16, 2024 · 5 comments · Fixed by #179
Assignees
Labels
2D Issues concerning 2D scenes 3D Issues concerning 3D scenes bug Something isn't working

Comments

@HappyHeads
Copy link

Issue description

I have a 144hz monitor and camera movement is very jittery in 3D and 2D when I have VSync on or framerate cap at an odd number. From my limited testing it seems to be an issue when the physics process happens at a different framerate compare to the monitors refresh rate. One way I found to solve the issue is to change _process inside phantom camera code to _physics_process but I'm not sure if there are any side effects to doing that. I know that physics jitter is a known issue with Godot itself but I wonder if there is specific ways to properly avoid it with phantom camera since its going to be a problem if players will have inconsistent framerate too.

Steps to reproduce

  • Have VSync or framerate cap turned on
  • Make sure that physics ticks per second is a different number that is not divisible by by your monitor refresh rate (for example if you have a 60hz monitor change the physics ticks per second to different number that is not divisible by 60)
  • Check one of the example scenes like 2DExampleScene.tscn or 3DFollowSimpleExampleScene.tscn for jitter when the character moves around

(Optional) Minimal reproduction project

No response

@ramokz
Copy link
Owner

ramokz commented Jan 16, 2024

Thanks for reporting this! This was an issue early on in the project, but had a hunch there were still things to do for this.

So have tested on both a 120hz and 60hz monitor.

Can't seem to replicate any jitter when V-Sync is enabled, or disabled, on either monitor — it has apparently been enabled for me the entire time. Not sure if the reason you're seeing it is due to having a higher refresh rate than me, though annoyingly can't check that.

But can see what you mean regarding the uneven / non-divisible by 60 physics tick per second value. The concern about _physics_process should only be for the Camera2D/3D itself, within the PhantomCameraHost.gd, which should ideally be kept in the _process. The addon was initially using the _physics_process to move the Camera2D/3D, again, within PhantomCameraHost.gd. It was changed to only move in the _process after the _physics_process had run because it caused issues at certain monitor refresh rates, typically highers ones.

However, moving the PhamtomCamera2D/3D positional changes to the _physics_process does seem stable in any physics tick per second value when checking on both monitors and on two devices. So your suggestion seems like a valid solution to try out. If anything, it looks better than the existing one.

@ramokz
Copy link
Owner

ramokz commented Jan 16, 2024

I'll make a PR and try to gather some feedback for about a week or so.

If no one screams or shouts about it, I'll merge it in and submit an update.

@ramokz ramokz self-assigned this Jan 16, 2024
@ramokz ramokz added bug Something isn't working 3D Issues concerning 3D scenes 2D Issues concerning 2D scenes labels Jan 16, 2024
@P5ina
Copy link
Contributor

P5ina commented Jan 17, 2024

This is not a problem of phantom camera, you should tween your visuals in process. I have the same issue and I resolved it by using this library (I found it on godot's docs page). But to work this with phantom camera you need to use my PR #179 that fixes camera being affected by _physics_process

@Lasuch69
Copy link

Mind that when using Third Person Mode, spring arm causes a bit of jitter too.

@ramokz ramokz linked a pull request Jan 18, 2024 that will close this issue
@ramokz
Copy link
Owner

ramokz commented Jan 19, 2024

Resolved in #179

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2D Issues concerning 2D scenes 3D Issues concerning 3D scenes bug Something isn't working
Projects
None yet
4 participants