Movement
Player movement is controlled by the handle_movement function in the player script, which is called in _physics_process. It uses the direction variable that is synced from the player_input node.
player_input generated the direction vector based on the direction the player intends to move relative to the camera, i.e. the movement keys are used to determine the 2D horizontal movement vector, which is then rotated according to the orientation of the camera.
Jumping is detected in player_input, and when a jump occurs, the jumping variable is set to true vie rpc, to ensure that the call is properly detected and handled.
As the 2D horizontal movement direction and jumping are synced variables, the server and all peers can use these two variables to process the movement of a player, while only requiring the camera scene to exist locally. While all peers process the movement of all players, the server syncs the position and orientation of all players with all peers, and thus overrides potential local deviations on peers. Peers process movement only to reduce lag.
Movement speed is a separate variable, with which the resulting velocity gained from the direction vector is multiplied. This movement speed variable is considered a stat that can be changed by talents, buff, debuffs, etc., but in the absence of such modifications movement speed is equal for all players.
No Comments