Skip to content

Latest commit

 

History

History
29 lines (16 loc) · 1.95 KB

File metadata and controls

29 lines (16 loc) · 1.95 KB

HelloNetcode Remote Player Input Prediction

A players input can be predicted based on the previous values seen in his input buffer. This sample is exactly like the Spawn Player sample before but tweaked to enable remote player input prediction feature.

See

Requirements

Connection needs to be in game already and scripts from the player spawning sample are re-used.

  • GoInGame
  • SpawnPlayer

Sample description

The input struct and player prefab have changes for remote player prediction but otherwise this is the same sample as Spawn Player. On the prefab we have these changes:

  • Supported Ghost Modes toggle. Changed to Predicted since all the player ghosts are now only running in prediction mode and we don't spawn interpolated players.

Inputs are set up using IInputComponentData as in Spawn Player but now each variable has the [GhostField] attribute set which will make the input buffer be synchronized to all non-owner players. The ghost component attributes doesn't need to be further tweaked as the default values are configured for this scenario. A [GhostComponent] attribute is now also added which specifies the input struct should only appear on the predicted ghost prefab (AllPredicted prefab type).

The RemotePredictedPlayerAutoCommands.cs script is a duplicate of the Spawn Player auto command script except it is configure to work on the RemotePredictedPlayerInput input struct.

Notes

The players in this sample might look pretty much identical to the non-predicted players in the previous sample. To be sure inputs are actually synchronized you can look at the input buffers on the spawned remote players using the DOTS Hierarchy window.