Local peer missing
Connecting to server gives me the error The peer is unknown (current local peer ID). If I set the controller's peer to 1, then every half a second, it says The local peer was not found. This is a bug. PeerID: (current local peer ID)
func _setup_synchronizer(local_id: int) -> void:
GameSync.setup_controller(
self,
get_multiplayer_authority(),
collect_inputs,
count_input_size,
are_inputs_different,
controller_process
)
E 0:00:11:0390 cube.gd:15 @ _setup_synchronizer(): The peer is unknown `866995536`.
<C++ Error> Condition "pd" is false. Returning: nullptr
<C++ Source> modules\network_synchronizer\scene_synchronizer.cpp:1547 @ NS::SceneSynchronizerBase::get_controller_for_peer()
<Stack Trace> cube.gd:15 @ _setup_synchronizer()
cube.gd:8 @ _ready()
3d.gd:88 @ spawn()
func _setup_synchronizer(local_id: int) -> void:
GameSync.setup_controller(
self,
1,
collect_inputs,
count_input_size,
are_inputs_different,
controller_process
)
E 0:00:06:0849 NS::SceneSynchronizerBase::rpc_notify_netstats: The local peer was not found. This is a bug. PeerID: 1088757787
<C++ Error> Condition "local_peer_data" is false. Returning: m_retval
<C++ Source> modules\network_synchronizer\scene_synchronizer.cpp:1178 @ NS::SceneSynchronizerBase::rpc_notify_netstats()
Hey! To the setup_controller function you want to pass the local_id.
The correct syntax is:
func _setup_synchronizer(local_id: int) -> void:
GameSync.setup_controller(
self,
local_id,
collect_inputs,
count_input_size,
are_inputs_different,
controller_process
)
Thanks so much! Quick heads up that the documentation for GdScenceSynchronizer says to use get_multiplayer_authority.
https://github.com/GameNetworking/NetworkSynchronizer/blob/03fef0931c41766bea7e4085a9305ed339cecb2e/doc_classes/GdSceneSynchronizer.xml#L23-L29
It also appears that I'm getting a similar issue when using local_id:
E 0:00:02:0012 cube.gd:15 @ _setup_synchronizer(): The peer is unknown `0`.
<C++ Error> Condition "pd" is false. Returning: nullptr
<C++ Source> modules\network_synchronizer\scene_synchronizer.cpp:1547 @ NS::SceneSynchronizerBase::get_controller_for_peer()
<Stack Trace> cube.gd:15 @ _setup_synchronizer()
cube.gd:8 @ _ready()
3d.gd:88 @ spawn()
Is it possible that I might've done something else incorrectly?
The peer 0 doesn't exist, I thinks you are exchanging local_id with peer_id. Can you please paste the code you are using here?
Sure! Here it is:
Level script:
extends Node3D
var gamers := {}
var peer: ENetMultiplayerPeer
const cube = preload("res://cube.tscn")
...
# This is the function that is called when a peer connects
func dude_connected(id: int) -> void:
prints(id,"connected")
for gamer:int in gamers:
print(gamer)
spawn.rpc_id(id,gamer)
spawn(id)
print(id)
spawn.rpc(id)
...
# This is the function that creates a cube
@rpc("authority","call_remote","reliable") func spawn(id: int) -> void:
prints(multiplayer.get_unique_id(),"spawning player %s"%id)
var player := cube.instantiate()
player.set_multiplayer_authority(id)
player.name = str(id)
add_child(player)
player.position.y = 0.5
gamers[id] = player
Character (cube) script:
extends CharacterBody3D
var inputs := Vector2.ZERO
func _ready() -> void:
GameSync.register_node(self)
func _exit_tree() -> void:
GameSync.unregister_node(self)
func _setup_synchronizer(local_id: int) -> void:
prints(local_id, "setting up", get_multiplayer_authority())
GameSync.setup_controller(
self,
local_id,
collect_inputs,
count_input_size,
are_inputs_different,
controller_process
)
GameSync.register_variables(self,net_vars)
func collect_inputs(delta: float, buffer: DataBuffer) -> void:
inputs = Input.get_vector(&"ui_left",&"ui_right",&"ui_up",&"ui_down")
buffer.add_vector2(inputs)
func count_input_size(inputs: DataBuffer) -> int:
return inputs.get_vector2_size()
func are_inputs_different(i1: DataBuffer, i2: DataBuffer) -> bool:
if i1.size() != i2.size():
return true
var one := i1.read_vector2()
var two := i2.read_vector2()
return one != two
func controller_process(delta: float, buffer: DataBuffer) -> void:
inputs = buffer.read_vector2()
velocity.x = inputs.x
velocity.z = inputs.y
move_and_slide()
const net_vars: Array[StringName] = [
&"position",
&"velocity",
]
GameSync singleton
extends GdSceneSynchronizer
func _ready() -> void:
frame_confirmation_timespan = 0.
prints("fps",get_frames_per_seconds())
prints("peer networking",get_peer_networking_enabled(multiplayer.get_unique_id()))
var registered_variables: Dictionary
func register_variables(node: Node, vars: Array[StringName]) -> void:
registered_variables[node] = vars
for variable in vars:
register_variable(node,variable)
Just checking in-- is my code not working because I did something wrong?