Godot Version
Godot Engine v4.3.stable.steam.77dcf97d8
Question
I throw the towel, I am stuck on one simple problem for the 6th day now.
I’m trying to make a first person perspective multiplayer game, but I have an issue where if you add a player prefab from peer_connected call but the prefab has client authority, you CANNOT modify it. Something as simple as setting a position of a newly spawned player CANNOT be set by the server, or by any other client for that matter.
Some people say that it works if you set position before adding the child, but it’s simply not true - this doesn’t work either (example code below).
One solution I have found to this whole issue is to have server authority over player prefabs. I followed many guides of the legend Battery Acid Dev (like this video) and he seems to like server authority approach for his TPP games - the problem is if you go this way you get input delay. Now it’s not a lot and it’s not as noticable for TPP games, but it is enough to be subconsciously noticable in FPP since it is equal to the ping of the player, and well - first person perspective movement with input delay just feels awful.
Can somebody please tell me how can I solve this seemingly basic issue? How can I keep client authority for player prefab so I have sharp client side movement, but so that I can also manipulate its fields like position via server? I suppose some kind of RPC call would solve all of it but I just cannot find an elegant solution to this problem.
Example of a code that doesn’t work for client authoritive player prefab (and how I set client authority for said prefab). The general idea for this I got from this video.
# gameplay scene code
[...]
multiplayer.peer_connected.connect(add_player)
[...]
func add_player(id = 1):
var player = player_scene.instantiate() as Node3D
player.name = str(id)
player.position = Vector3(10, 0, 10) # <- spawns at 0, 0, 0 regardless
call_deferred("add_child", player)
# player prefab code
func _enter_tree():
set_multiplayer_authority(name.to_int())