Godot Version
v4.2.1
Question
I have some code that allows a host to create a server and spawn next to a defined spawn point. Clients can join and spawn, however they are positioning at 0,0,0 instead of the spawn point. They can otherwise move and see/be seen by the host correctly.
The players ServerSynchronizer is set to ‘spawn’ and ‘always’. I’ve checked that the player is being added to the correct node.
The add_player function instantiates the clients character, sets the id/name, positions it and adds it to a dedicated, empty node.
func add_player(id: int):
# Instantiate a player and spawn it
var character = preload("res://player.tscn").instantiate()
# Set player id.
character.player = id
# Set player name
character.name = str(id)
# Get the position of the appropriate spawn point
var spawnPoint = get_node("mship1").position
print("Ship position: ", spawnPoint)
# Move the player to that position
character.position = Vector3(spawnPoint.x, spawnPoint.y + 20, spawnPoint.z - 20)
print("Character position: ", character.position)
$Players.add_child(character, true)
I’ve then added a print to the players ready function to confirm its position
func _ready():
# Give authority over the player input to the appropriate peer.
if not is_multiplayer_authority(): return
# Set the camera as current if we are this player.
if str(name).to_int() == multiplayer.get_unique_id():
$Camera3D.current = true
#var camera = $Camera3D.current
capture_mouse()
print("Players 'on ready' position: ", position)
When run, the host prints:
Ship position: (292.334, 22.0841, 724.584)
Character position: (292.334, 42.0841, 704.584)
Players 'on ready' position: (292.334, 42.0841, 704.584)
The client prints
Ship position: (292.334, 22.0841, 724.584)
Character position: (292.334, 42.0841, 704.584)
Players 'on ready' position: (0, 0, 0)
My best guess is this is some kind of client/server permission issue, but tbh its got me stumped.