Hey Godoters,
I'm currently working on a small project that I'm trying to add multiplayer functionality to. For some reason, when a second player joins the server, all of the variables on each person's player nodes reverts to null. I have all the basic functionality working, the two instances of the game both run independently and both players can see each other moving independently of each other, so there's no problems there. The game is 3D and kind of like an RTS where players spawn units that they send down a central lane to attack each other.
example one:
I have two string variables on the player scene: Current Team and Opponent Team
When the first player (host) joins, a player scene is added to the tree, the peer is given authority over it, and their current team now becomes "Blue" and opponent team becomes "Red", when a second player (client) connects, the same thing happens but their current team becomes "Red", opponent is "Blue". I use strings to make signal calls depending on which team is executing an action. However, once the second player joins, their current and opponent teams are set correctly and then immediately all players get null values for their variables.
example two:
On the player scene, I have a linked scene called "Placer" which handles the unit UI menu and placing a selected unit in the world based on where the player's mouse is. When the player scene is in ready(), it passes a reference of itself to the placer scene so that the placer can get reference to the player's mouse location in world space which is calculated in a function within the player script and stored in a variable. When an instance of the game hosts, the player is able to spawn in units as normal. When a client joins the server, the client is able to spawn in units, but when the host tries to spawn in units, the variable that stores the player's mouse position becomes null.
Is there something I'm missing with regards to multiplayer set up? I can provide more information if necessary. I've tried using the multiplayer synchronizer on the player scene to sync the mouse location variable and the team variables but this doesn't seem to work.