When using a MultiplayerSynchronizer to only sync a property on spawn, the property does not seem to synchronize. I feel there must be something wrong with my setup but I can't see it. I have a basic project created to test this here.
I made it about as simple as I could. Two buttons, one hosts a server and sets the value for "_testingSanity" to true. The Join button connects to the server and should print a message saying the value has been synced.
using Godot;
using System;
public partial class main : Control
{
// Multiplayer setup
private ENetMultiplayerPeer _multiplayerPeer;
private int _multiplayerPort = 9999;
private const string MultiplayerAddress = "127.0.0.1";
private bool _testingSanity = false;
[Export]
public bool TestingSanity
{
get
{
return _testingSanity;
}
set
{
// No need for server to run this
if (Multiplayer.IsServer())
return;
_testingSanity = value;
GD.Print("Client testing sanity .. it worked!");
}
}
public override void _Ready()
{
_multiplayerPeer = new ENetMultiplayerPeer();
}
public void HostPressed()
{
_multiplayerPeer.CreateServer(_multiplayerPort);
GD.Print($"Server started");
Multiplayer.MultiplayerPeer = _multiplayerPeer;
TestingSanity = _testingSanity = true;
}
public void JoinPressed()
{
_multiplayerPeer.CreateClient(MultiplayerAddress, _multiplayerPort);
GD.Print($"Client joined");
Multiplayer.MultiplayerPeer = _multiplayerPeer;
}
}
The value does not get set on the client.
If I enable "Sync" on the replication for the MultiplayerSynchronizer as well it will sync (repeatedly). But I don't need to be flooding the network with this data, the value will never change.
Is there something wrong with my setup?