Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Photon, How to get player variable

I’m putting Photon into my project but I would like to find out if a player is ready with customplayerproperties.

I’ve been able to set them using:

    Hashtable hash = new Hashtable();
    hash.Add("ready", false);
    PhotonNetwork.LocalPlayer.SetCustomProperties(hash);

But then I have no idea how to get that information back again from all players.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I have tried this method:

public override void OnPlayerPropertiesUpdate(Player target, ExitGames.Client.Photon.Hashtable changedProps)
{
    base.OnPlayerPropertiesUpdate(target, changedProps);
    
    if (!PhotonNetwork.IsMasterClient) 
        return;
    if (!changedProps.ContainsKey("ready"))
        return;
}

But when compiled into Unity I get the error:

The type or namespace name 'Player' could not be found (are you missing a using directive or an assembly reference?)

And I get another error for that override being:

'PlayerReadied.OnPlayerPropertiesUpdate(Player, Hashtable)': no suitable method found to override

I don’t know what to do here, if anyone could help that would be great!!

I really appreciate any help you can provide.

>Solution :

Check your ‘using’ statements in that file, it should have these I think:

using Photon.Pun;
using Photon.Realtime;

Maybe related, if you are upgrading from Photon Unity Networking 1 to 2, there were namespace changes that might give you those issues: https://doc.photonengine.com/en-us/pun/current/getting-started/migration-notes

Edit Do you have a ‘Player’ class in your program as well? I think your ‘Player’ class is being used in that method signature instead of PUN’s one.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading