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

Fixed jitter while walking and rotating at the same time. #128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mmhanson
Copy link

@mmhanson mmhanson commented Jun 1, 2021

Bug Description

The blocks on screen jitter when the player walks horizontally and rotates simultaneously.

Bug Reproduction

Walk to the side and rotate the camera at the same time.

Bug Cause

The bug is caused by a lack of synchronization between the on_mouse_update method, which updates the player rotation, and the update method, which updates the player position.

Bug Fix

In the on_mouse_update method of the Window class, instead of immediately updating the player rotation, buffer the updates. Then, in the update method of the same class, update the player position and player rotation at the same time.

Made rotation smoother by buffering changes in rotation made by the on_mouse_motion callback, and adding them later in the update method. Updating the position and rotation at the same time removes the jittery which appears while walking and moving your sight simultaneously.
@Aareon
Copy link

Aareon commented Sep 17, 2021

Tested and jitter is removed, but it appears this math is quite a bit more expensive now. I had consistently >60fps prior to testing, and have seen dips to ~28fps with the update on my, truthfully, borderline antiquated hardware.

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

Successfully merging this pull request may close these issues.

None yet

2 participants