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

Fix inputs handling in FixedUpdate #349

Closed
cBournhonesque opened this issue May 13, 2024 · 1 comment · Fixed by Leafwing-Studios/leafwing-input-manager#522
Closed

Fix inputs handling in FixedUpdate #349

cBournhonesque opened this issue May 13, 2024 · 1 comment · Fixed by Leafwing-Studios/leafwing-input-manager#522
Labels
A-Input Related to handling user inputs

Comments

@cBournhonesque
Copy link
Owner

cBournhonesque commented May 13, 2024

Pre-requisite knowledge:

  • JustPressed becomes Pressed in a system that runs in PreUpdate (so once-per-frame).
  • leafwing systems do not run in FixedUpdate
  • lightyear handles inputs in FixedUpdate, to have access to tick information

Basically the problem is that:

  • if you use just_pressed in FixedUpdate: you can have frames where FixedUpdate doesn't run, so the JustPressed becomes Pressed and just_pressed() misses the input
  • if you use just_pressed in Update: I actually cannot remember the exact problem here.. I think it's that the tick-number in Update is not reliable. There's no guarantee that it would be the same as in the server, so you might get off-by-1 errors.

The solution to use pressed in FixedUpdate and consume the action. I think it works, but it generates more diffs than necessary (wasted bandwidth) because of some leafwing issue

Relevant leafwing issue: bevyengine/bevy#6183

@cBournhonesque cBournhonesque added the A-Input Related to handling user inputs label May 13, 2024
@cBournhonesque cBournhonesque changed the title Inputs are kind of a footgun Fix inputs handling in FixedUpdate May 13, 2024
@cBournhonesque
Copy link
Owner Author

This is now fixed, handling inputs in FixedUpdate should now work as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Input Related to handling user inputs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant