expressobits / character-controller

Modular Character Controller for Godot 4. Includes FPS version with headbob and camera movement. (Walk, Crouch, Sprint, Swim and Fly Mode).
https://godotengine.org/asset-library/asset/1567
MIT License
310 stars 13 forks source link

Jittering when moving and rotating at high FPS ? #28

Closed Mysterius closed 6 months ago

Mysterius commented 10 months ago

Hello,

I just started experimenting with this controller. One thing I noticed is that objects in my scene "jitter" when I move around them while rotating the mouse to try to keep them in focus. Simply moving or simply rotating doesn't cause this problem, only when trying to do both at the same time.

The problem is only visible at high FPS (more than 60), and the higher the more jitter I see.

I tried taking a video of the problem and I do have one here : https://github.com/expressobits/character-controller/assets/4077266/dce346ff-27e8-4b21-8c5f-cbb45e62aabc

But... be warned that the problem is only visible on the video when you have a screen refresh rate higher than 60 (and the higher the jittering).

I'm not sure I understand the dynamics behind this problem so I would appreciate an explaination if someone understands what's happening.

I could of course limit FPS to 60 but I'd like to let players chose more if they wish.

Mysterius commented 10 months ago

Solved by using physics interpolation. For anyone looking it up, try Smoother or Interpolated Camera3D.

I'm letting the issue open since I think there could be an internal option for this in the asset, but feel free to close it if you think this it outside the scope of what you want to achieve.

scriptsengineer commented 10 months ago

Solved by using physics interpolation. For anyone looking it up, try Smoother or Interpolated Camera3D.

I'm letting the issue open since I think there could be an internal option for this in the asset, but feel free to close it if you think this it outside the scope of what you want to achieve.

I'm thinking it might be something related to the head bob camera animation, test disabling this and see if it continues.

Mysterius commented 10 months ago

It isn't, the video I posted is with all bobbing options disabled. This is most likely related to framerate inconsistencies heavily discussed here : https://www.reddit.com/r/godot/comments/wh6vw5/is_there_really_no_proper_fix_to_jittering/

Hence why interpolation solved the problem.

scriptsengineer commented 6 months ago

The error occurs because it transformed the quaternion of the headbob rotation into vector3, even when it was deactivated, it did this conversion, creating the flick Fixed in version 2.1.7 https://github.com/expressobits/character-controller/commit/8e59df183f2d7b54a44240706e84f49c2ad13c37#diff-254b1f47c3f536f9904a5b520a3691c2d9174626ec39e237219daed26d8ad545R117