blog: Add client prediction to "Multiplayer in Godot 4.0: Scene Replication" (#576)

This commit is contained in:
Fabio Alessandrelli
2023-02-26 17:34:46 +01:00
committed by GitHub
parent a0d12db986
commit 80659ee387
3 changed files with 3 additions and 2 deletions

View File

@@ -226,7 +226,8 @@ func _ready():
if player == multiplayer.get_unique_id():
$Camera3D.current = true
# Only process on server.
set_physics_process(multiplayer.is_server())
# EDIT: Let the client simulate player movement too to compesate network input latency.
# set_physics_process(multiplayer.is_server())
func _physics_process(delta):
@@ -253,7 +254,7 @@ func _physics_process(delta):
move_and_slide()
```
We will then use the server synchronizer to keep the position in sync and to set the player id on spawn (which will in turn configure the appropriate input authority).
We will then use the server synchronizer to keep the position and velocity in sync and to set the player id on spawn (which will in turn configure the appropriate input authority).
![Server synchronizer](/storage/blog/multiplayer-in-godot-4-0-scene-replication/player_server_sync.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 169 KiB

After

Width:  |  Height:  |  Size: 176 KiB