Hi all, i want to ask a question about unet binary serialization. The problem is that i can’t save data to server’s pc, codes are always trying to do it on client’s pc. Here is the code
[Command]
void CmdDisablePlayer()
{
playerManagerScript.RemovePlayer(gameObject);
NetworkManagerEdited.singleton.StopClient();
NetworkManagerEdited.singleton.StopHost();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
public void RemovePlayer(GameObject _player)
{
PlayerLoadInfos infos = new PlayerLoadInfos();
infos.playerName = _player.name;
infos.playerPositionX = _player.transform.position.x;
infos.playerPositionY = _player.transform.position.y;
infos.playerPositionZ = _player.transform.position.z;
players.Remove(_player);
//Store player properties in database
StorePlayerData(infos);
}
void StorePlayerData(PlayerLoadInfos _infos)
{
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Create(Application.persistentDataPath + "/Saves/" + serverNamePrivate + "/Players/" + _infos.playerName + ".dat");
bf.Serialize(file, _infos);
file.Close();
}
first code (cmd) is on player object, second one is on a non-static object.