fix(multiplayer): replicate per-player avatar loadout and preserve original materials
checkpoint / checkpoint (push) Successful in 5m57s
checkpoint / checkpoint (push) Successful in 5m57s
This commit is contained in:
@@ -42,6 +42,7 @@ var peer: ENetMultiplayerPeer
|
||||
var my_peer_id: int = 0
|
||||
var _server_root: Node
|
||||
var _player_proxy: Node
|
||||
var pending_loadout: Dictionary = {}
|
||||
|
||||
var _seq: int = 0
|
||||
## Ring buffer of {seq, move_x, move_z, jump, delta, position, velocity},
|
||||
@@ -100,6 +101,8 @@ func _on_connected() -> void:
|
||||
_server_root.add_child(_player_proxy)
|
||||
|
||||
connected_to_server.emit()
|
||||
if not pending_loadout.is_empty():
|
||||
_player_proxy.rpc_id(1, "rpc_set_loadout", pending_loadout)
|
||||
|
||||
|
||||
func disconnect_from_server() -> void:
|
||||
@@ -258,3 +261,12 @@ func send_input(move_x: float, move_z: float, jump: bool, look_yaw: float) -> vo
|
||||
if _player_proxy and is_instance_valid(_player_proxy):
|
||||
_player_proxy.rpc_id(1, "rpc_request_input",
|
||||
{"move_x": move_x, "move_z": move_z, "jump": jump, "look_yaw": look_yaw}, _seq)
|
||||
|
||||
|
||||
## Send the local player's avatar loadout to the server so it can be replicated
|
||||
## to other clients.
|
||||
func send_loadout(loadout_dict: Dictionary) -> void:
|
||||
pending_loadout = loadout_dict.duplicate(true)
|
||||
if _player_proxy and is_instance_valid(_player_proxy):
|
||||
_player_proxy.rpc_id(1, "rpc_set_loadout", pending_loadout)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user