Search Unity

Third Party Photon Unity Networking

Discussion in 'Multiplayer' started by tobiass, Aug 23, 2011.

  1. SunnyChow

    SunnyChow

    Joined:
    Jun 6, 2013
    Posts:
    360
    I see Photon offers a self-host server feature. i would like to ask. Is it suitable for a offline LAN project, which several mobile devices connect to a computer server through wifi?
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    @whidzee: Player is not a static type in PUN. This must collide with some other Player class.
    Let's try one thing: Modify the AsteroidsGameManager to include this:
    using Player = Photon.Realtime.Player;
    Add this below the "using Hashtable" line.
    We will have a look.

    @Wothanar: Glad to read you found a solution that works. Awesome!
     
  3. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    I can not reproduce this:

    - can you try on an empty project, with just pun 2. Do you get this error still?

    You likely have a conflict with another framework/script that use a class Player or something.

    we defined our Player class inside the namespace Photon.Realtime but if a script defines a Player Class in the default namespace ( without a namespace), then it can conflict.

    - Can you search your project for Player classes? do you have another one then the one from Photon?

    Bye,

    Jean
     
  4. utkarshdwivedi3997

    utkarshdwivedi3997

    Joined:
    Aug 11, 2017
    Posts:
    25
    How does the
    EventCaching.RemoveFromRoomCacheForActorsLeft
    option work in when raising events?

    Is it
    a) When raising an event with this option, it makes sure that the event will be cleared when the player that called it leaves?
    or
    b) I have to call it separately using
    EventCache.AddToRoomCache
    , and then when a player leaves, call it again with
    EventCaching.RemoveFromRoomCacheForActorsLeft
    ?
     
  5. JohnTube

    JohnTube

    Joined:
    Sep 29, 2014
    Posts:
    66
    Hi @utkarshdwivedi3997

    Thank you for choosing Photon!

    It's neither a) nor b).
    EventCaching.RemoveFromRoomCacheForActorsLeft
    removes all cached events -if any- for all actors already gone -if any-.
    This option makes sense only if the room was created using
    RoomOptions.CleanupCacheOnLeave = false
    .

    "Cached Events" documentation page.
     
  6. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    We updated PUN 2 again. There was some back and forth for the EventData class but now it's back to usable (and configurable). Sorry for any hassle.

    v2.12 (6. May 2019)
    Fixed: Breaking change of EventData. The properties Sender and CustomData are back and they keys (in the event Parameters) can now be configured at runtime (if needed).
    Updated: To new library version 4.1.2.14 (6. May 2019 - rev5088).
    v2.11 (3. May 2019)
    Fixed: EventData usage. PUN v2.10 had a bug in Ownership Transfer calls and some events.
    Fixed: ClientState.ConnectedToMasterserver did not have the same value as ConnectedToMasterServer (and no longer got used at all). This affects only rare cases where the enum is directly used (PUN was updated).
    Changed: Account registration scripts to use Unity's built-in JSON parsing. Now, PUN no longer incldues the NewtonSoft Json dll (which should avoid the occasional clash of dlls).
    Updated: To new library version 4.1.2.13 (3. May 2019 - rev5086).
    Changed: EventData was changed in the Photon3Unity3d.dll again. Now it does not have a Sender or CustomData property anymore as those were not workign for Chat (and misleading). Instead, those are fetched from the Parameters of an event (each API provides accessor extensions).
    Added: PhotonPeer.ReuseEventInstance as option to use a single EventData instance for all incoming events. This reduces memory garbage. The drawback is: An event provided via OnEvent(EventData photonEvent) is invalidated right after the callback finished. That event's content will get modified. Typically this is not a problem as events are rarely cached.
    Chat
    Fixed: Properly add local client's UserId to public channels' Subscribers list when applicable.
     
  7. utkarshdwivedi3997

    utkarshdwivedi3997

    Joined:
    Aug 11, 2017
    Posts:
    25
    Hey! Thanks for the response.

    I read the documentation, but I'm still confused as to how to go about using the
    RoomOptions.CleanupCacheOnLeave
    .
    So, I have some events that need to be cached, but removed from the cache when a player leaves. I'm thinking of making a remove event call in the
    OnPlayerLeftRoom
    callback. Still, though, would I have to make the event call with the remove cache option for every single cached event, or would it remove ALL cached events (with different event codes) for that player.

    And would this also remove buffered RPCs, or is that something that needs to be handled differently?

    Edit: Just found out about
    PhotonNetwork.OpRemoveCompleteCacheOfPlayer(Player otherPlayer)
    . Does this also remove events raised by otherPlayer?
     
    Last edited: May 6, 2019
  8. JohnTube

    JohnTube

    Joined:
    Sep 29, 2014
    Posts:
    66
    Hi @utkarshdwivedi3997

    Why not just keep the default value of
    RoomOptions.CleanupCacheOnLeave
    which is
    true
    ? This way when a player leaves the room for good, all cached events he raised will be removed.

    Buffered RPCs and network instantiation calls are cached events.

    PhotonNetwork.OpRemoveCompleteCacheOfPlayer(Player otherPlayer)
    will remove all cached events raised by that otherPlayer.
    It makes use of
    CachingOption.RemoveFromRoomCache
    . This is also documented here.
     
  9. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    423
    Hello,

    Is there a simple way with photon to somehow block the pirated users of the game? And also without breaking cross-platform multiplayer?

    I can think of basically using the Game Version that we can set-up for Photon, and perhaps causing client with old Game Version to be rejected with some callback and showing a related popup to update the game.

    For example, version 1.0 is pirated and then we updated the game to 1.1, those pirates would normally still be able to play online without updating the game, even though I can give different Game Versions to these builds and seperate the players, what I want to do is to block pirated version 1.0 with some setting in photon cloud.

    Or perhaps using a password key embedded in the build that we can setup in the cloud dashboard. And when game is pirated we can just release a new build, change the password required in cloud dashboard, and force the players from the old version to update.

    An example: I set the 1.0 versions password to 1234 and connect to server with this password.
    Then the game was pirated, and in updated version 1.5 I change the password to 5678 to connect.
    When update is released, I change from the cloud dashboard to only accept the password 5678 and show a popup for players with the old version to force them to update for multiplayer.

    This would be even better if we can set to accept multiple passwords or versions as legit in the dashboard, or perhaps block some list of versions.

    Is it possible right now without custom server and complicated authentication setup?

    Thanks.
     
  10. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    Without authentication, this is not possible, sorry.
    We would guess that we'd have to modify such a system quite frequently, to stay on top of requirements and to consistently beat the various hacks and pirated variants. Each game will have different needs, so we instead try to support a generic solution with authentication. This is the only way to reject players from connecting.

    A simple authentication service should not be very complex to build. You don't have to verify connections versus a user-database and you can implement your own, secret rules to reject players as needed. This way, you may be able to stay ahead of pirates.
     
  11. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    814
    I think the easy way could be the string for version you use hwen "connect using" lets say "v1.45_pc"

    you in the photon settings hav ea field for "required version" like where it is an string field.

    and you get a callback for non matching strings where you could then trigger a ui message like "game update is required" or something like that so you can keep killing non updated pirated versions. You could even just up an update where just the verison number increases for instance.
     
  12. ccvannorman

    ccvannorman

    Joined:
    Jan 20, 2013
    Posts:
    13
    The Asteroids demo works locally only, with 2 versions running on my own computer, but when I send it to my friend in another state, neither of us can see the other one after creating a room. What's going on?

    I cannot find a straighforwards tutorial that says what the settings need to be to allow two players to connect remotely.

    Here are my settings. As far as I can tell from the documentation, this should be working, but it doesn't.
     

    Attached Files:

  13. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    423
    I was surprised to hear that's not a much-requested feature, then I made a forum search and found more people asking for the same feature;
    https://forum.unity.com/threads/photon-unity-networking.101734/page-30#post-3053070
    https://forum.unity.com/threads/photon-unity-networking.101734/page-22#post-2377658
    https://forum.unity.com/threads/photon-unity-networking.101734/page-33#post-3322969
    https://forum.unity.com/threads/photon-unity-networking.101734/page-23#post-2471790
    https://forum.unity.com/threads/photon-unity-networking.101734/page-25#post-2728023

    Anyways, if you are not planning to work on it, can you please direct me to the easiest and best way to do this version check?
    What we need is, to have a list of "AcceptedVersionKeys" in the server, and the server will check if the version of the client is available in this list, and return to photon accordingly.
    -With minimal downtime, so I don't wish to use our website's server, perhaps we can use webscript.io? Edit: webscript.io is discontinued.
    Or are there alternatives to webscript.io with low downtime? And a service that has a lower chance of being discontinued after i.e. 1-2 years.
    -Is there a sample code for the server script? I am a Unity c# developer and I have no experience programming a server or PHP or anything.
    Have I understood correctly that we can set photon to skip authentication if the authentication server can not be reached?

    Thanks for your support.
     
    Last edited: May 25, 2019
  14. JohnTube

    JohnTube

    Joined:
    Sep 29, 2014
    Posts:
    66
    Hi @ccvannorman,

    Thank you for choosing Photon!

    You need to go through the "Matchmaking Checklist", you and your friends are probably connected to different regions.
     
  15. JohnTube

    JohnTube

    Joined:
    Sep 29, 2014
    Posts:
    66
    Hi @Meceka

    Thank you for choosing Photon!

    We have switched from webscript.io to webtask.io but we cannot guarantee that such service will stay forever.
    I think you can have a working PHP script in a day to get custom auth request parameter, compare AppVersion provided by the client to a static (hardcoded) whitelist (or a blacklist) then returning proper JSON response.
    If you are going that way just tell us if you got stuck with all the details and we will try our best to help.

    If you're interested you could also achieve this using PlayFab by using the integration with Photon in an unorthodox (but OK) way to achieve the AppVersion filter.

    "Have I understood correctly that we can set photon to skip authentication if the authentication server can not be reached?" Yes, this is possible if you untick "Reject If Unavailable".
     
  16. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    Does anyone have a code example for changing a RoomProperty in Photon using CAS, that includes the error handling? (PUN v1)

    I have a float[] as a custom property. The various players can change elements of the float array. However, because of concurrency, while I try to change one element, another player may try to change a different element.

    Ultimately what I am looking for (psuedocode)

    ChangeRoomProperties()
    {
    ReadRoomProperties() //casting them to an array[]
    alter the desired element
    recreate Hashtable
    room.SetCustomProperties(prop, oldvalueProp);
    if error == incorrect oldValueProp
    {
    ChangeRoomProperties()
    }
    }

    Is a flag set or anything to tell you the attempted CAS write failed?

    Per the docs.

    https://doc.photonengine.com/en-us/pun/current/gameplay/synchronization-and-state

    "SetCustomProperties has an optional expectedValues parameter, which can be used as condition. With expectedValues, the server will only update the properties, if its current key-values match the ones in expectedValues. Updates with outdated expectedValues will be ignored (the clients get an error as a result, others won't notice the failed update).
     
    Munchy2007 likes this.
  17. JohnTube

    JohnTube

    Joined:
    Sep 29, 2014
    Posts:
    66
    I have replied on our Photon forum here.
     
    Munchy2007 likes this.
  18. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    297
    Hi @tobiass ,
    In android on application exit, I get the ThreadAbortException. I do call both
    chatClient.Disconnect();
    chatClient.StopThread();
    still i get this issue. The issue exists only in IL2CPP build. Here is the message
    Code (CSharp):
    1. ThreadAbortException
    2. at ExitGames.Client.Photon.SupportClass+<>c__DisplayClass6_0.<StartBackgroundCalls>b__0 () [0x00000] in <00000000000000000000000000000000>:0
    3. at System.Threading.ThreadStart.Invoke () [0x00000] in <00000000000000000000000000000000>:0
    4. at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0
    5. at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0
    6. at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0
    7. at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Objec
    [Edit]
    Using PUN 2

    [Edit2]
    this one from debug build
    Code (CSharp):
    1. : ThreadAbortException
    2. 06-06 16:25:35.933  5487  5561 E Unity   :   at System.Threading.Thread.SleepInternal (System.Int32 millisecondsTimeout) [0x00000] in <00000000000000000000000000000000>:0
    3. 06-06 16:25:35.933  5487  5561 E Unity   :   at System.Threading.Thread.Sleep (System.Int32 millisecondsTimeout) [0x00000] in <00000000000000000000000000000000>:0
    4. 06-06 16:25:35.933  5487  5561 E Unity   :   at ExitGames.Client.Photon.SupportClass+<>c__DisplayClass6_0.<StartBackgroundCalls>b__0 () [0x00000] in <00000000000000000000000000000000>:0
    5. 06-06 16:25:35.933  5487  5561 E Unity   :   at System.Threading.ThreadStart.Invoke () [0x00000] in <00000000000000000000000000000000>:0
    6. 06-06 16:25:35.933  5487  5561 E Unity   :   at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00000] in <00000000000000000000000000000000>:0
    7. 06-06 16:25:35.933  5487  5561 E Unity   :   at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0
    8. 06-06 16:25:35.933  5487  5561 E Unity   :   at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0
    9. 06-06 16:25:35.933  5487  5561 E Unity   :   at System.Thre
     
    Last edited: Jun 6, 2019
  19. payalzariya07

    payalzariya07

    Joined:
    Oct 5, 2018
    Posts:
    85
    Not Joint For created Room

    I´m new to Networking and can´t find the problem on my self. I made a matchmaking system for my game and it worked well. But after some changes in my Game it stopped working.

    It should create a room if no room is there. Else join a random room. But it always creates a new room. no errors etc.

    here are the scripts that should do the work.

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;
    using Photon;



    public class Mpmanager : Photon.MonoBehaviour
    {


    public string connectversion ="1.1";

    public static Mpmanager m;
    public int curplayer = 0;
    public Text connectiontxt;
    public Text k;
    void Start()
    {
    m = this;
    ConnectTomaster();
    OnConnectedToMaster();
    //if (!PhotonNetwork.connected)
    //{
    // PhotonNetwork.ConnectUsingSettings("1.0");
    //}
    }

    // Update is called once per frame
    void Update()
    {
    //curplayer = PhotonNetwork.pla.Length + 1;

    }
    private void FixedUpdate()
    {
    connectiontxt.text = PhotonNetwork.connectionStateDetailed.ToString();

    }
    public void ConnectTomaster()
    {
    Debug.Log("COnnect to masster:");
    PhotonNetwork.ConnectUsingSettings(connectversion);

    }
    public virtual void OnConnectedToMaster()
    {
    Debug.Log("COnnect to master");

    //Pm.hideLogin();
    }
    public void CreateOrJoined()
    {
    Debug.Log("CreateOrJoined");
    PhotonNetwork.JoinRandomRoom();
    }
    public virtual void OnPhotonRandomJoinFailed()
    {
    RoomOptions rm = new RoomOptions
    {
    MaxPlayers = 2,
    isVisible = true

    };
    int ranid = Random.Range(0, 3000);
    PhotonNetwork.CreateRoom("Default: " + ranid, rm, TypedLobby.Default);

    Debug.Log("OnPhotonRandomJoinFailed");

    }

    public virtual void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
    if (stream.isWriting)
    {
    stream.SendNext(curplayer);
    }
    else if (stream.isReading)
    {
    curplayer = (int)stream.ReceiveNext();
    }
    Debug.Log("OnPhotonSerializeView");
    }
    public virtual void OnJoinedRoom()
    {

    photonView.RPC("AddPlayercount", PhotonTargets.All);
    k.text = PhotonNetwork.room.name + "Room name/ player " + PhotonNetwork.room.PlayerCount.ToString();
    Debug.Log("OnJoinedRoom");
    }
    [PunRPC]
    void AddPlayercount()
    {
    curplayer++;
    Debug.Log("CP " + curplayer);
    }

    public void LeaveRoom()
    {
    PhotonNetwork.LeaveRoom();
    Debug.Log("CP " + curplayer);
    }
    }

    Plaese help me why my game every time generate different room in game.

    Thanks in Advance.
     
  20. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    Which Unity version is it and which runtime do you use? We will try to reproduce.
    Have a look at the included script ConnectAndJoinRandom. It does what you describe and could be a blueprint.
    Also have a look at the Matchmaking Checklist.
     
  21. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    297
    @tobiass
    Latest store version of PUN2. 2.12
    Unity Version 2019.1.0f2
    IL2CPP
    .Net 4.x and .net standard 2.0
     
  22. Ali-Be

    Ali-Be

    Joined:
    Aug 29, 2012
    Posts:
    11
    We are having the same issue as sathya.
    Latest store version of PUN2. 2.12
    Unity Version 2019.1.5f1
    IL2CPP Zrzut ekranu 2019-06-13 09.29.39.png .Net 4.x
     
  23. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    423
    Hello,

    I have a question about instantiation.

    I'm using PUN2.
    I used to instantiate the same prefab even for other players (IsMine==false) using the normal way of PhotonNetwork.Instantiate to load from resources.

    However, for other players (IsMine==false) we don't need those complicated prefabs with so many scripts, gameobjects, rigidbodies, colliders, textures and etc. So we used to trim multiplayer prefabs right after instantiation.

    We realised that this causes unnecessary loading time and also can cause the app to crash for some platforms because of very high memory usage just after entering an already full room with versatile prefabs.

    So I decided to make this trimming operation in the editor by a script, save the prefab beside the original prefab with a _multi name tag, and I want photon to instantiate this prefab if the instantiation is for IsTheirs.

    In example, there is a room with 1 player. I join that. On my game instance,
    Photon instantiates the original prefab for myself.
    Photon instantiates the trimmed prefab with _multi tag as theirs.

    No trimming operation is done in runtime.

    How is this possible with Photon?

    Thanks,
    Mehmet
     
  24. Alex3333

    Alex3333

    Joined:
    Dec 29, 2014
    Posts:
    342
    When will there be support from NET 4 ?? I need this environment in the project, but it will stop working as the photon does not support it.
     
  25. JohnTube

    JohnTube

    Joined:
    Sep 29, 2014
    Posts:
    66
    Hi @Ali-Be,

    Thank you for choosing Photon!

    There are issues cropping up in Unity 2019 and we would not be surprised if this is fixed since the original release.

    Please update Unity and try to repro.

    release history of 2019.1.1:
    IL2CPP: Fixed an intermittent crash when a managed exception occurs on a back ground thread while the process is shutting down.
    release history of 2019.1.2:
    Services: Fix crash in signal handler on Android IL2CPP ARM64
     
  26. JohnTube

    JohnTube

    Joined:
    Sep 29, 2014
    Posts:
    66
    Hi @Alex3333,

    Thank you for choosing Photon!

    Photon already supports .Net 4.
    What Unity version did you try?
    Did you get any error?
     
  27. JohnTube

    JohnTube

    Joined:
    Sep 29, 2014
    Posts:
    66
    Hi @Meceka,

    This is not available out-of-the-box.
    Why do you need to strip the remote client's local prefab instance? maybe just disable the components?

    Otherwise, you need to modify PUN code or implement a custom manual instantiation.

    I don't know if this is a good idea worth being a feature request.
    @tobiass what do you think?
     
  28. Alex3333

    Alex3333

    Joined:
    Dec 29, 2014
    Posts:
    342

    I'm sorry. Really !! This is amazing !! Thank !!
     
  29. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    423
    In our case those prefabs are vehicles. Vehicles have interiors and other unnecessary detail that we don't want for remote client's local prefab instance, because of performance.

    There are 27 vehicles in our game. When there are many players with different vehicles in the room it increases memory usage a lot just after loading. The interiors and all material, mesh and texture references are destroyed after instantiation but also needs to removed from the garbage.

    It crashes on some platforms right now because of this reason. Even if we can prevent it from crashing it increases loading and instantiation time, also creates unnecessary garbage.

    There are also many complicated physically moving parts with hinge joints and customizable joints and multiple rigidbodies. For remote client's local prefab we just need one kinematic rigidbody without joints. So we delete all of them after instantiation and it's right now not working well.

    I trim lots of unnecessary gameobjects and components that aren't used in multiplayer. Actually, the _multi prefab that I generated by editor script has 1/3 the number of gameobjects. And I also plan to have just 1 box collider for the remote client's local prefab. Original prefab has up to 10 primitive colliders and multiple triggers.

    Also, a different hierarchy structure for _multi prefab would be easier to manage for our case.

    How can I make this instantiation work? Would it work with "Manual Instantion" which is explained here?
    https://doc.photonengine.com/en-us/pun/current/gameplay/instantiation
     
  30. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,735
    There are instances where I would definitely find it useful to be able to specify a different prefab for remote clients and the local client.

    At the moment I've been using the 'disable components/gameobjects approach, but this can get kind of messy.
     
  31. SurbhiPrakashLS

    SurbhiPrakashLS

    Joined:
    Feb 5, 2019
    Posts:
    4
    Hi, i am working on a multiplayer game,using photon for multiplayer mode.
    Issue 1: On iPhoneX i am unable to accept/reject friends game invite. This functionality is working fine with all other device (iPhone/iPad) but not with IPhoneX. When i run my app's Xcode directly on my IphoneX(phone connected to MAC system and run Xcode) then the accept/reject invite works, but not when app is installed on the device.

    Issue 2: While over wifi i get "DisconnectByClientTimeOut" error, but not i use 4G network.

    Stuck with this from a last few days, Please Help.
     
  32. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    @sathya: We have a fix for this and will update PUN in the next week. Sorry for letting you wait.

    @Meceka: We think it makes sense to have just one prefab/type to instantiate and then modify it as needed for local and remote use. In your case, I suggest to instantiate the minimal prefab and if it's local, add stuff as needed. Basically: Turn the workflow around and make it lean by default.
    Alternatively, don't make all objects networked right away. Instantiate a network view on demand, when someone is using them. You could parent the object/visuals to a new networked object.

    @Munchy2007: I think both approaches can be messy. Especially if you could use both in one project. You'd always have to look up which approach you use and have to keep the prefabs in sync. Overall, this seems to be an organizational issue which probably won't go away either way.
    I'm happy to be convinced otherwise.

    @SurbhiPrakashLS: Photon does not provide friend invites as such. Also, our code is pretty much device agnostic, so if different iOS devices succeed or fail, it's probably more a timing issue or something else.
    When the WiFi is giving you a bad connection, check the connectivity and if the devices shape your traffic. In our office, we have two WiFi routers and one of them is good while the other has frequent lag spikes up to several seconds (and timeouts).
    If you didn't yet, check this: https://doc.photonengine.com/en-us/pun/current/reference/analyzing-disconnects
    The next PUN updates will have an improvement for connections where ping temporarily goes up.
     
  33. JohnTube

    JohnTube

    Joined:
    Sep 29, 2014
    Posts:
    66
    Hi @SurbhiPrakashLS

    Thank you for choosing Photon!

    Issue 1: This is unrelated to Photon. There is no accept or reject friends in any of the Photon products.
    Issue 2: Check out "Analyzing Disconnects" documentation page.
     
  34. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    We just updated the PUN package in the Asset Store.
    Most important updates are bold. The PUN 2 package was briefly tested in the alpha Unity 2019.3.0a6 and it seemed to work.

    v2.13 (25. June 2019)
    Added: Options for OpFindFriends to filter which rooms should be returned by the server. The default is the same as before but now the friend list may exclude rooms which are not yet on the game server, invisible, closed (or any combination).
    Fixed: Typos and null checks in PhotonNetwork class.
    Fixed: SerializationProtocol selection for WebGL.
    Fixed: Missing IWebRpcCallback interface reference added to MonoBehaviourPunCallbacks.
    Added: PhotonNetwork.AllocateViewID(bool sceneObject), which can be used to just get a viewID that is then assigned manually.
    Updated: Improved wording for warning on missing photonViews during serialization.
    Changed: The library now has a changes-realtime.txt file instead of a release_history.txt. The plan is to separate library and Realtime API updates from those of PUN and other packages. Also check out changes-realtime.txt and changes-library.txt.
    Updated: PUN Cockpit. It will now rejoin instead of join if needed.
    Updated: To new library version 4.1.2.16.
    This fixes an issue with a ThreadAbortException thrown on Android (with specific Unity build settings) and improves connection stability in cases where the ping goes up temporarily.
    Chat
    Added: ChatClient.TryGetPrivateChannelByUser.

    v1.98 (25. June 2019)
    Added: Options for OpFindFriends to filter which rooms should be returned by the server. The default is the same as before but now the friend list may exclude rooms which are not yet on the game server, invisible, closed (or any combination).
    Fixed: SerializationProtocol selection for WebGL.
    Updated: To new library version 4.1.2.16. This fixes an issue with a ThreadAbortException thrown on Android (with specific Unity build settings) and improves connection stability in cases where the ping goes up temporarily.
    Photon Chat:
    Added: ChatClient.TryGetPrivateChannelByUser.
     
    Last edited: Jun 25, 2019
    Munchy2007 likes this.
  35. JohnTube

    JohnTube

    Joined:
    Sep 29, 2014
    Posts:
    66
    Hey @Ali-Be @sathya

    ICYMI:

    PUN 2.13 is out with a new library v4.1.2.16 in its changelog:

    "Fixed: Each thread created via SupportClass.StartBackgroundCalls will now try-catch a ThreadAbortException. Apparently, the handling of a ThreadAbortException changed with Unity 2019, which started to log the exceptions on IL2CPP, 4.x runtime."
     
    sathya and Ali-Be like this.
  36. utkarshdwivedi3997

    utkarshdwivedi3997

    Joined:
    Aug 11, 2017
    Posts:
    25
    I upgraded my project from Unity 2018.2.14f1 to Unity 2019.1.8f1 and I'm getting some errors with PUN2 that I wasn't getting before. Does PUN2 not support 2019.1.8f1 yet or are there certain things that changed that I'll have to take into account?

    These errors I'm getting are of the type GameObject with View ID already exists (the one where it tells you to uncheck Don't Destroy on Load). These objects don't have DDOL, but are player prefabs that get spawned (there are more than one spawned clone because it's a multiplayer game). I'm getting these errors in OFFLINE mode for some reason.
     
  37. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    Can you paste the errors you get?

    Yes, PUN2 supports all public versions of Unity. So let's see what the errors are so we can propress in finding the source of the issue.

    Bye,

    Jean
     
    JohnTube likes this.
  38. utkarshdwivedi3997

    utkarshdwivedi3997

    Joined:
    Aug 11, 2017
    Posts:
    25
    Turns out I just needed to upgrade PUN 2 to its latest version. The errors are gone. Thanks for the reply though!
     
    tobiass likes this.
  39. eron82

    eron82

    Joined:
    Mar 10, 2017
    Posts:
    83
    In Unity (2018.4.4) i have no issue but if i build the game i have this error when i click the button to connect:

    MissingMethodException: Constructor on type 'ExitGames.Client.Photon.SocketUdpAsync' not found.
     
  40. eron82

    eron82

    Joined:
    Mar 10, 2017
    Posts:
    83
    I have no issue if i select Managed Stripping Level: "disabled" instead of "low". Please fix it.
     
  41. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    It's a case where Unity's stripping is over-eager. You can reign it in by modifying the link.xml file in your project to retain the class (or simply all of the Photon dll).

    Open the file and modify the beginning (e.g.) to:


    Note: That snipped above is incomplete!
     
    JohnTube likes this.
  42. ddalacu

    ddalacu

    Joined:
    May 13, 2014
    Posts:
    31
    Hello, we are getting the following error "The appId this client sent is unknown on the server (Cloud). Check settings. If using the Cloud, check account." when building with cloud build on unity 2018.4.4, note that the error does not show on local builds on same version, do anyone have any idea of what s happening? We are using ConnectUsingSettings() to connect and the app id is set in PhotonServerSettings.
     
  43. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    @ddalacu: That sounds odd. The PhotonServerSettings are a scriptable object and a file in the project.
    I never used Cloud Build, so bear my ignorance. Make sure the PhotonServerSettings are part of what you submit to be built and that there is just one instance of that. If there are two files (in different folders), something is causing the system to create another instance and read that when built via Cloud Build.
     
  44. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
    Is PUN 2 based on the current UNET that will be deprecated, or is it "future proof" for the next few years?
     
  45. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    PUN is fully independent from uNet and any solution that Unity implements.
    Photon Realtime (the basis for PUN and Quantum) also runs without Unity and there are libraries for clients in various languages, such as C++ and ObjC.

    Yes, it's positively future proof.
     
    mrCharli3 likes this.
  46. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    We just updated the Asset Store with PUN 2.14.
    It's a slightly bigger update with plenty of fixes and improvements, so we suggest to everyone to update.
    Read the changelog carefully to update your project. Here's an extract:

    The lowest supported Unity is now 2017.4.7. The Asset Store no longer supports uploading packets for older Unity versions.
    Compatibility with Unity 2019.1 and 2019.2 has been improved. Among other things, the PhotonEditor could fail to load the PhotonServerSettings when loading a project without "library" folder, which showed as a lost app id.
    Callbacks registration had a few edge cases, which could be resolved. Among other things, duplicate addition and removal is now prevented.
    Getting disconnected now has just one callback to OnDisconnected(reason). The state should be Disconnected by then and you can ReconnectAndRejoin right in the callback.
    Fixed the RPC listing, which was incomplete due to the assembly definitions.
    The Editor integration has been refactored and should be leaner. Also, we fixed a few Editor UI issues. Now showing current best region and its ping from Players' Prefs in ServerSettings.
    ViewID assignment for scenes is refactored to not change viewIDs that were assigned before. If a new value clashes, that (changed) viewID is corrected.
    Option to dispatch incoming messages, even if Time.timeScale = 0: PhotonNetwork.MinimalTimeScaleToDispatchInFixedUpdate.
    PUN now disconnects in OnDisable, if OnApplicationQuit was called previously - you can now send a final message in OnApplicationQuit.
    Updated: To new library version v4.1.2.17. Fixed a problem with TCP connections which go entirely silent.
     
    Munchy2007 likes this.
  47. Filiperool

    Filiperool

    Joined:
    Jun 13, 2015
    Posts:
    1
    Hey, i am learning to use pun2 and create my first multiplayer fps game, i was able to setup everything and i can enter a room with other people, but when we enter the room the only people who will have position information are people who entered first. to everyone who enters later they will see everyone in the "spawn" position.
    I would like some guidance on how should i approach this problem.
     
  48. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,735
    It depends to some extent on how you have set things up in your game, but one approach is to have existing players listen for the 'player entered room' event and then use an RPC or RaiseEvent to send their current position/rotation (and anything else that might need to be synced) to the player that joined.
     
  49. Alex3333

    Alex3333

    Joined:
    Dec 29, 2014
    Posts:
    342
    Good day. Updated the photon to the latest version. now there are 2 errors from voice chat. how to fix them?
     

    Attached Files:

  50. Le_Hieu

    Le_Hieu

    Joined:
    Mar 26, 2011
    Posts:
    31
    Hi i used PUN 2 ver 2.14, Unity 2019.1.12
    built game in webgl and can't connect photon, error shown:
    MissingMethodException: Constructor on type 'ExitGames.Client.Photon.SocketWebTcp' not found.
    at System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0

    (Filename: currently not available on il2cpp Line: -1)