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

Custom input prediction function? #69

Open
johanhelsing opened this issue Nov 18, 2023 · 2 comments
Open

Custom input prediction function? #69

johanhelsing opened this issue Nov 18, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@johanhelsing
Copy link
Contributor

johanhelsing commented Nov 18, 2023

Is your feature request related to a problem? Please describe.

In some cases, it would be convenient to be able to send one-off events as part of the input struct:

struct Input {
    fire_just_pressed: bool,
    jump_held: bool,
}

However, when predicting, we would then get fire_just_presed == true repeatedly when predicting.

Describe the solution you'd like

Instead of just copying the input struct, perhaps it would make sense to be able to inject a prediction function?

session_builder.with_input_prediction(|input| {
    Input { fire_just_pressed: false, ..input }
})

let prediction_to_return = self.prediction; // PlayerInput has copy semantics

Describe alternatives you've considered

Handling just_pressed logic inside the ggrs advance frame step works as a workaround, but sometimes the events you get from game engines are one-offs (bevy ui button press events etc.), so it generates a lot of boilerplate

Additional context

https://discord.com/channels/844211600009199626/844211600009199629/1175361006717898763

@johanhelsing johanhelsing added the enhancement New feature or request label Nov 18, 2023
@aleksa2808
Copy link

I was just about to make an issue about this, awesome timing!

This functionality would be very helpful in my game as the current ggrs behavior causes a lot of mispredictions in the mentioned cases of one-off events (every input in my game). Currently I'm just using a patched version of ggrs where I always assume the inputs are inactive.

@gschup
Copy link
Owner

gschup commented Nov 25, 2023

I think that optionally providing a function for input predictions sounds great.

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

No branches or pull requests

3 participants