Photon.LoadLevel is overriding LocalPlayer.SetCustomProperties?

Hi all, I'm having trouble setting custom player properties within the same room when using

PhotonNetwork.LocalPlayer.SetCustomProperties and a call to load a different scene in the next few lines with PhotonNetwork.LoadLevel.

I set up / call SetCustomProperties and LoadLevel here:

public void functionOne()
{
    this.PhotonView.RPC("functionTwo", RpcTarget.ALL, "uselessString");
    PhotonNetwork.LoadLevel(6);
}    

public void functionTwo(String uselessString)
{
    playerShipPositions = new ExitGames.Client.Photon.Hashtable();
    int i = 0;
    string keyID;

    //add every element of shipList to this table

    foreach (Vector2 position in shipPositions)

    {

      keyID = i.ToString();

      playerShipPositions[keyID] = position.ToString();

      i++;

    }

    PhotonNetwork.LocalPlayer.SetCustomProperties(playerShipPositions);
}

Then I use an overridden OnPlayerPropertiesUpdate() to retrieve the data on each client here:

public override void OnPlayerPropertiesUpdate(Player targetPlayer, ExitGames.Client.Photon.Hashtable changedProps)
    {
        base.OnPlayerPropertiesUpdate(targetPlayer, changedProps);
        this.photonView.RPC("recievePlayerData", RpcTarget.Others, "test");
         //I tried putting the LoadLevel call here but same outcome sadly

    }


Somehow when I exclude the "PhotonNetwork.LoadLevel(6)" call everything works flawlessly, each player receives the other players data perfectly. When I do include the LoadLevel call though, all values in LocalPlayer.CustomProperties turn out null - I access this through:

PhotonNetwork.PlayerListOthers[0].CustomProperties

Null as in, the hashtable Count turns out 0, nothing at all is inserted into the table.


I've run through this countless times with the debugger, and my "playerShipPositions" hashtable is always full of keys/values, but it's like the setCustomProperties never gets set?

I've tried doing this in all different ways - switching the location of the call to LoadLevel to inside of "OnPlayerPropertiesUpdate", using scenemanager instead of PhotonNetwork...it's like the call to LoadLevel is happening ahead of the call to set custom properties somehow?


Sorry if this is a repeat question, i'm super new to Photon, everything's been smooth so far but I just can't seem to figure this out, been debugging for 3 days now.. Any help or advice is greatly appreciated!!

Answers

  • PS: When I tried putting the call into "OnPlayerPropertiesUpdate", the OnPlayerPropertiesUpdate was never even called.