[Code Sharing] Pun 2 Stuff

S_Oliver
S_Oliver ✭✭✭
edited March 2020 in Tutorials and Code Sharing
Hi,
i just decided to share all my stuff i used for developing Games with photon.

https://github.com/SradnickDev/Photon-Misc

Not everything available yet, because i have to clean stuff up, simplify and add some comments.
  • Property Wrapper
  • Team Extension
  • Property View / Debugging
  • Bulk Batch Sync (sync lots of units)
  • Authentication
  • Basic Health & Shooting
  • State Buffer
  • Data Compression/Packing
  • Ready check after Async Scene Load
  • Player Spawn - Spawnpoints

I also tryin to create a demo scenes.
Have fun.

Comments

  • Do you know how to use RPC or RaiseEvent to send Text to other players? I am doing a project, when Player1 get an integer: score, the score will be Text by using ToString(). Then, Player2 should start to play. But, before Player2 play, Player2 need to see the score that Player1 has got. How should I do it?
  • @Herman : You'd use player properties for that. There is even an extension in PUN Utilities to make this even easier.
    Look up PunPlayerScores.cs.
    Here's some background: https://doc.photonengine.com/en-us/pun/current/gameplay/synchronization-and-state
  • @Tobias admin: I have a problem when I try to use player properties.

    It says: NullReferenceException: Object reference not set to an instance of an object.

    However, I already declare the Text and int. Here is my simplified code.

    public Text [] PlayerScoreArray = new Text [4]; // Declare Text.
    static public int [] PlayerGetScore = new int [4]; // Declare int.
    bool OneRound; // Declare bool.

    private ExitGames.Client.Photon.Hashtable _myCustomProperties = new ExitGames.Client.Photon.Hashtable(); // Declare player properties.


    public void OnClick_GetScore()
    {
    OneRound = true; // if button clicked, boolean will be true.
    }

    void Update()
    {
    if(OneRound == true)
    {
    OneRound = false;
    PlayerGetScore[0] = 100; // Player get 100 score.
    PlayerScoreArray[0].text = PlayerGetScore[0].ToString(); //Display the score in Text
    }

    _myCustomProperties["InternetScore"] = PlayerGetScore[0]; // Send the score to player properties
    PhotonNetwork.LocalPlayer.CustomProperties = _myCustomProperties;
    int result = (int)PhotonNetwork.LocalPlayer.CustomProperties["InternetScore"]; //Receive player properties data
    PlayerScoreArray[0].text = result.ToString(); //Display the data. Also, here is the error code. I already declare "PlayerScoreArray" above.
    }
  • It says: NullReferenceException: Object reference not set to an instance of an object.

    However, I already declare the Text and int.

    Well. The runtime will be right. Some value is null and apparently you don't declare it as expected.
    I can't help with this sort of errors. It's "the usual" debugging problem and not really networking related.

    In doubt, check if the value is null and if so, don't run your code on it. See what that does.
  • S_Oliver
    S_Oliver ✭✭✭
    edited April 2020
    S_Oliver wrote: »
    Not everything available yet, because i have to clean stuff up, simplify and add some comments.
    • Property Wrapper
    • Team Extension
    • Property View / Debugging
    • Bulk Batch Sync (sync lots of units)
    • Authentication
    • Basic Health & Shooting
    • State Buffer
    • Data Compression/Packing
    • Ready check after Async Scene Load
    • Player Spawn - Spawnpoints

    updated^^
  • S_Oliver
    S_Oliver ✭✭✭
    https://www.youtube.com/watch?v=EkF21XVqsuE

    Added a drag n drop room chat^^
    https://github.com/SradnickDev/Photon-Misc/tree/master/Assets/Chat

    The next thing i'll work on, is about Animtion and IK sync, since i only have to extract it from an old project ;)