docs.rs failed to build lightyear_inputs_native-0.23.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
lightyear_inputs_native-0.21.1
Module to handle client inputs
Client inputs are generated by the user and sent to the server. They have to be handled separately from other messages, for several reasons:
- the history of inputs might need to be saved on the client to perform rollback and client-prediction
- we not only send the input for tick T, but we also include the inputs for the last N ticks before T. This redundancy helps ensure that the server isn't missing any client inputs even if a packet gets lost
- we must provide
SystemSet
s so that the user can order their systems before and after the input handling
Adding a new input type
An input type must be serializable, Reflect
, MapEntities
, Clone
, PartialEq
, and Debug
.
You can then add the input type by adding the InputPlugin<InputType>
to your app.
# use App;
# use ;
# use ;
# use Reflect;
use *;
// every input must implement MapEntities
let mut app = new;
app.add_plugins;
Sending inputs
There are several steps to use the InputPlugin
:
- (optional) read the inputs from an external signal (mouse click or keyboard press, for instance)
- to buffer inputs for each tick. This is done by setting the input value in the
ActionState
component. That system must run in theWriteClientInputs
system set, in theFixedPreUpdate
stage. - handle inputs in your game logic in systems that run in the
FixedUpdate
schedule. These systems will read the inputs using theActionState
component