CoherenceInput
This component can be added to a GameObject with CoherenceSync to be able to define which inputs it accepts.
This feature can be used to improve game feel and to prevent cheating by replaying inputs on a simulator or another client. See the coherence docs (section "Input prediction and rollback") for more information.
Fields
DestroyOnInputAuthorityDisconnected | Defines whether the simulator or host that has the state authority over this entity should destroy it when the client with input authority disconnects from the session. |
DisconnectOnTimeReset | Defines whether the client should automatically disconnect in case of unexpected time resync with the server. |
InitialBufferSize | Size of the buffer. Dictates how many frames worth of inputs can be stored. When buffer reaches its capacity a pause is requested through the ShouldPause(long, long). |
InitialInputDelay | Delay applied to the stored inputs. |
MaxInputs | Defines the maximum number of input Fields. |
UseFixedSimulationFrames | If true the input system will use ClientFixedSimulationFrame, otherwise ClientSimulationFrame will be used. |
Properties
Buffer | Returns an underlying input buffer. |
BufferSize | Size of the buffer. Dictates how many frames worth of inputs can be stored. When buffer reaches its capacity a pause is requested through the ShouldPause(long, long). |
CurrentSimulationFrame | Current simulation frame as seen by this client. If the UseFixedSimulationFrames is true this returns ClientFixedSimulationFrame, otherwise ClientSimulationFrame is returned. |
Delay | Delay applied to the stored inputs. |
Fields | Contains the field definitions to be used. |
IsInputOwner | Determines whether this client is responsible for producing inputs using |
IsProducer | If true, this client is responsible for producing inputs using |
IsReadyToProcessInputs | Determines whether this input is ready for processing input data.
Until this is true, all the inputs set through
the |
IsServerSimulated | If true the input system assumes that there's a simulator or host running that processes all inputs sent by the clients while clients merely produce inputs and sync their entities with the host. Authority over this entity will be automatically transferred to the host. |
LastAcknowledgedFrame | Last frame received that didn't trigger a misprediction, or -1 if nothing was acknowledged yet. Might be greater than LastConsumedFrame. |
LastConsumedFrame | Last frame that was fetched from the buffer and was not predicted. |
LastFrame | Last (latest) frame number for which an input was stored, received or predicted. -1 if nothing was added to the buffer yet. |
LastReceivedFrame | Last frame number that was received from the remote input producer, or -1 if nothing was received yet. |
LastSentFrame | Last frame number that was dequeued for sending, or -1 if nothing was sent yet. |
MispredictionFrame | Frame at which last prediction failure has been detected. |
ProcessingEnabled | Determines whether the input processing will happen. If false, inputs won't be stored in the buffer and won't be sent. Affects only the input-producing side. Defaults to true. |
Methods
DebugOnInputReceived | |
DebugOnInputSent | |
GetAxis | Returns a state of the axis as of the given simulation frame. |
GetAxis2D | Returns a state of the axis2D as of the given simulation frame. |
GetAxis3D | Returns a state of the axis3D as of the given simulation frame. |
GetButton | Returns a state of the button as of the given simulation frame. |
GetInteger | Returns a state of the integer as of the given simulation frame. |
GetRotation | Returns a state of the rotation as of the given simulation frame. |
GetString | Returns a string state as of the given simulation frame. |
SetAxis | Sets an axis state for this input. Input is stored as of the CurrentSimulationFrame. |
SetAxis2D | Sets an axis2D state for this input. Input is stored as of the CurrentSimulationFrame. |
SetAxis3D | Sets an axis3D state for this input. Input is stored as of the CurrentSimulationFrame. |
SetButton | Sets a button state for this input. Input is stored as of the CurrentSimulationFrame. |
SetInteger | Sets an integer state for this input. Input is stored as of the CurrentSimulationFrame. |
SetRotation | Sets a rotation state for this input. Input is stored as of the CurrentSimulationFrame. |
SetString | Sets a string state for this input. Input is stored as of the CurrentSimulationFrame. |
ShouldPause | If true, the buffer cannot do any more predictions. Client should pause the game and stop polling inputs to not lose any data required for a rollback. |
Update | Update event. |
Events
OnStaleInput | Called when an input is received that is older than the oldest input in the buffer. |