cBournhonesque / lightyear

A networking library to make multiplayer games for the Bevy game engine
https://cbournhonesque.github.io/lightyear/book
Apache License 2.0
409 stars 42 forks source link

Don't send input if <condition> #610

Closed simbleau closed 6 days ago

simbleau commented 2 weeks ago

My game has chat. If the user starts typing, I want to ignore inputs.

They may send a message that uses the keys WASD - Which are used for movement.

However I can't find a way to tell Lightyear not to send the input if state.typing is true.

What should I do?

cBournhonesque commented 2 weeks ago

With the leafwing input it is possible to disable leafwing ActionStates and systems. There is an open issue to also stop replicating inputs from client->server if the inputs are disabled on the client: https://github.com/cBournhonesque/lightyear/issues/507

For your specific use-case, you could use run-conditions or states to at least no send inputs on the client while the chat window is open (lightyear would still send inputs to the server, but those inputs would be empty)

simbleau commented 1 week ago

Good idea!

How would I implement the last part? The sending of inputs is automatic via adding an input plugin to the protocol plugin.

cBournhonesque commented 1 week ago

I meant that you can make sure to call ActionState.disable() while the chat window is open, which means that the ActionState will be empty. It will still be replicated to the server but the state will be small