Are all resetState commands called before all new commands?

I have multiple EntityEventListener components for a Bolt state for the same Entity. Each deals with its relevant state properties (one for movement, one for weapons, etc.). Can I be sure that when I'm executing a command in one of them, that all of the values are up to date in the others? Sometimes they need to reference values that are "reset" by other components. Is this an accepted way of doing things?

Comments

  • Also I forgot to ask the actual question in the title. Are ALL resets called before all new commands? Including across all Entities, so no new commands for any Entity will be received until all reset commands have been received?
  • First, let's break down how SimulateController/ExecuteCommand works. SimulateController is only invoked on the host which is in control of the entity, this can be both the owner (if it calls TakeControl() for itself) or a proxy (if the owner calls GiveControl(connection)).

    SimulateController is used for collecting input state from your game and putting it into a command, and other tasks specific to the controller. SimulateController executes one time per frame only.

    ExecuteCommand runs on both the owner and the controller of an entity, so if you have a player character which the server spawns and then gives control of it to a client, ExecuteCommand will run on both the server and the controlling client. It will not run on any other clients.

    The next question usually is: so how does the input/state work on the command, and what does resetState do?

    So, first of - input is very obvious, this is set on the command in SimulateController and polls the local state of whatever input scheme you are using for that specific frame. When you call QueueCommand(cmd); the command is scheduled both for local execute on the client and is sent to the server for remote execution. This is what lets Bolt do client side prediction: the command will execute on both the server and client.

    The state on the command, is the resulting state movement state of executing the input, this is why you copy the state of whatever character motor you are using to the command.

    When the server executes a command, it will send the State of the command back to the client which created the command, and override the state of that specific command on the client with its own correct state.

    So how does resetState fit into all of this? resetState asks you to reset the state of the character motor to the state of the command passed in when resetState is true. This will only happen on remote controlling clients, never on the server. This happens once at the beginning of every frame, and the command which is passed in is the command which has received its correct state from the server.

    After the command with resetState has execute, Bolt will execute *all* other commands again on the client, to "catch up" to the current state. This happens every frame.

  • Thanks for the reply. I think I understand all of that. If there are 2 entities being controlled by a single client, and they both need to be reset, will they both be reset before more commands are executed? Or is one reset then executed before the 2nd is reset then executed? I can probably just figure out a way to test this myself if I need to.