I pressed the "ready" button, but I received input data twice at the client . official example
I pressed the "ready" button, but I received input data twice at the client. This problem was found in the official example :“ Fusion-Tanknarok”
On "OnInput(NetworkRunner runner, NetworkInput input)" Function :
if (ToggleReady) { ToggleReady = false; _frameworkInput.Buttons |= NetworkInputData.READY; Debug.Log("上传Ready"); }
On "FixedUpdateNetwork" Function
if (input.IsDown(NetworkInputData.READY)) { Debug.Log($"player{_player.playerID}收到ready数据"); _player.ToggleReady(); }
this is result:
Best Answer
-
The client wouldn't pick up the item twice as long as your FixedUpdateNetwork implementation is correct. The reason for that is because Fusion will rollback all the game state including your [Networked] variables and transforms etc. before it re-runs the predicted simulation.
0
Answers
-
FixedUpdateNetwork can get called multiple times on the client with the same input. That's because during FixedUpdateNetwork on the client, the client is running a predicted simulation. Because the client can't predict this correctly it needs to resimulate this predicted simulation each time it receives a new snapshot from the server. During this resimulation all the predicted simulation steps are repeated with the already existing input values.
0 -
What should I do? For some logic, I just want to execute it once in FixedUpdateNetwork
0 -
What kind of logic are we talking about? The answer on what to do depends on what you are specifically trying to achieve.
0 -
For example, if I press the R button to pick up the item, and press the R button again to drop the item, because the client executes it twice, the client directly picks up the item and then drops it.
0 -
The client wouldn't pick up the item twice as long as your FixedUpdateNetwork implementation is correct. The reason for that is because Fusion will rollback all the game state including your [Networked] variables and transforms etc. before it re-runs the predicted simulation.
0 -
thank you very much
0