I’ve got an interesting bug with my game where a newly joined player’s position is equal to the position of the previous players current position.
Is there something I need to be doing with the multiplayer synchronizer that I’m not already doing? The root path is set to an empty node called “Players”. One would think it by default that would be the position of the new player?
If you are using MultiplayerSpawners they will add the new node to the parents origin. So it kind of sounds like the new player is being added under the last joined player?
If you don’t use an MP… There could be some funny business if you dynamically modify a replication config. Do you do such a thing?
If you are using MultiplayerSynchronizers only, I suspect there is a bug in your code. Maybe in setting the position of the new player. ( like local vs global position?)
Hi Penny,
No I can definitely comfirm after viewing remote that they are not creating a hierarchy chain. Every added player is the sibling of the previous player.
No, I’m not setting the position of the player programmatically at all. I’m using a MultiplayerSynchronizer to position the players.
How are you adding the player to the scene on the client? As a multiplayer synchronizer will not synchronized instantaneously, and will happen potentially frames after a node is spawned.
The issue was that the players were sharing the same collider layer and getting stuck inside eachother on frame 1 of the client joining even if the host isn’t at the start location. This is due to the delay in the multiplayerSynchronizer not updating the player position before the game has loaded the player.
This can be resolved with a MultiplayerSpawner and using the on spawn MultiplayerSynchronizer replication config setting.
Trust me I don’t have this issue, and since you don’t set the position they will spawn at the origin of your players node, and on top of each other. That isn’t a bug that is how add_child works.
Now just set a different position before adding the child to the scene.
Or, and I haven’t tied this, multiplayer spawner can spawn nested nodes under the branch it watches. You could make a simple spawner locations by having marker nodes with different positions and the host chooses which spawn node to add the new player. They will be set to that nodes origin. As long as two players aren’t set to the same node you don’t have to worry about spawning on top of each other.
Idk, I’m not sure… I don’t have this issue with my project. I think I have run into this issue but it’s typically solved by assigning a different position.
By chance, are you using a rigid body as your player? If so you will need to sync the physics body state instead of node position. I typically set position on spawn with never. then have another synchronizern handle the physics state with always.
I have posted my physics synchronizer code here. It is a work in progress, but should be bare bone enough for anyone to tune to there needs.
Another question, what authority do you give to the client? in other words, are you assigning the player node or just an input synchronizer? Is this a server-client architecture or peer-to-peer?
If you give the player node authority to the client this could explain why setting the position from the host isn’t working. Because it would be the responsibility of the client to set its own position.