I have a problem with MultiplayerSynchronizer and when i spawn a Platform.
I use PackedScene to spawn my Platform that i can stand on it (which is a CharacterBody2D) but client can’t spawn or see what host spawned and if he try to spawn on host scene and it take the postion of host mouse to spawn it
Here’s the code:
extends Node2D
@export var platform: PackedScene
@rpc("any_peer", "call_local", "reliable")
func add_node(nodePath: String):
if not multiplayer.is_server():
return
var newNode = load(nodePath).instantiate()
newNode.global_position = get_global_mouse_position()
add_child(newNode, false)
print(newNode)
func _input(event):
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
add_node.rpc(platform.get_path())
and this the error that shows:
get_node: Node not found: “Mulitplayer_test/platform_Manger/@CharacterBody2D@12/MultiplayerSynchronizer” (relative to “/root”).
<C++ Error> Method/function failed. Returning: nullptr
<C++ Source> scene/main/node.cpp:1638 @ get_node()
E 0:00:11:0108 process_simplify_path: Parameter “node” is null.
<C++ Source> modules/multiplayer/scene_cache_interface.cpp:76 @ process_simplify_path()
how is your players being managed?, do you have some kind of autoload just for the players? it’s not spawning because the platform is only spawned to the host
so basically to spawn the platform for both player, it needs to be similar to how you spawn the client and or host too. In the video i have sent, he needed to get the player by autoload (after setting all of connecting and have the player data) , then spawn the player in specified position
i found why it doesnt show now after testing it myself, global mouse position is true, it always spawn where the mouse is, so even for the client, it spawn where the mouse is, that is outside the window of client
i did use rpc and now i can spawn on host and it shows on client with no error but client can’t spawn on hist mouse postion he can only spawn on host mouse postion as you said and i tryed to use
but when i click to spawn on like (11, 11) it spawn on like (490, 249)