Search Unity

Third Party Photon PUN+

Discussion in 'Multiplayer' started by tobiass, Oct 9, 2013.

  1. jonkuze

    jonkuze

    Joined:
    Aug 19, 2012
    Posts:
    1,709
    Sorry for double posting... I will stick to the early access group for support for now. Thanks!
     
  2. BillO

    BillO

    Joined:
    Sep 26, 2010
    Posts:
    61
    I applied this method and it works fine. The network player appears/teleports to the correct location. I'm new to PUN so please forgive my ignorance, but OnPhotonSerializeView() will show Vector3.zero on any client that has stopped moving? So Update() will constantly show either true or false as the game is being played depending on the players movement?
     
  3. Akusan

    Akusan

    Joined:
    Aug 24, 2014
    Posts:
    12
    By the way, is there any Photon PUN+ Community chat room available?
     
  4. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    I do not work at Exit Games :D
     
  5. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    PUN will never call OnPhotonSerializeView() with a made-up position of Vector3.zero but it might stop calling OnPhotonSerializeView() if you set the PhotonView synchronization to "Unreliable on Change" or "Delta Compressed". Both will detect there are no new values to send and skip those updated.
     
  6. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    None we actively support, sorry. We try to be available in active forums like this and ours but there is no chat.
     
  7. BillO

    BillO

    Joined:
    Sep 26, 2010
    Posts:
    61
    As you suggested previously, with on Update(), I am checking if syncEndPodsition equals Vector3.zero. What made-up position of Vector3.zero are you referring to? Are there any examples in the online documentation?
     
  8. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    @BillO: Sorry, we don't have a good example for this. I will try to look into this for the next PUN update but can't promise anything.
    I was referring to this:
    PUN won't call OnPhotonSerializeView() if it received nothing new. If you got anything via OnPhotonSerializeView, in Update you should never have to lerp to .zero again.
     
  9. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    Just updated to v1.54, which should help solve trouble with iOS exports caused by websocket-csharp.dll.
    Please update.

    v1.54 (3. June 2015)

    Fixed: In Offline Mode, the NetworkingPeer.mMasterClientId always returns the local player ID. This fixes RPCs in offline mode targeted at the Master Client.
    Fixed: WebGL support no longer breaks other platform exports. Download the package from the Asset Store with Unity 5 to get WebGL support (Unity 4 can't handle it).
    Changed: WebSockets are now only used for the WebGL platform (in-editor and in export). You can't select WebSockets on any other platform (because we can't support the websocket-csharp.dll on each).
    Added: When you select "Best Region" as Hosting Type (in PhotonServerSettings), you can now select the regions that are enabled. Deselect those you don't want to use and they are dropped from the list of available regions (in the client, obviously).
    Changed: Setup Wizard. It's now considerably leaner. The idea is to improve the Inspector for the PhotonServerSettings some more. Working but also "Work in Progress".
    Fixed: A bug when setting properties via SetCustomProperties(propertiesToSet, expectedValues). Those updates were not sent reliable, so they could get lost and de-sync with any clients. This only affects currently updated clients which used this new feature (since v1.52). Thanks, Lino.
     
  10. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    And another update:

    v1.55 (12. June 2015)
    Changed: PhotonNetwork.time so that it's always positive, even on iOS 64bit exports. Note: this time value does not start at 0 and it will "wrap around" from 4294967.295 to 0! Use with care - we will implement a better soltion asap.
    Changed: ServerSettings.EnabledRegions (for "Best Region" Cloud hosting) now defaults to "all". The old default had the same effect but it was labelled as "none" of the regions (which is not allowed).
    Fixed: Re-creation of the PhotonServerSettings file in case you deleted a duplicate. This always created a file in the default location. Now, it does not matter where the PhotonSettingsFile is: If you have one at least, it will be found.
    Changed: AuthenticationValues now has a property UserId. You can set a UserId independent from the playerName now. This UserId should be unique per player and does not have to be readable. FindFriends will use this UserId (or one set by a Custom Auth Service). If you don't set it, PUN will use PhotonNetwork.playerName to identify a user.
    Changed: AuthenticationValues now uses AddAuthParameter(key, value) to set parameters. Simply call it once for each parameter that your authentication service expects. Changed GUICustomAuth accordingly.
     
  11. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    v1.56 (16. June 2015)
    Changed: The RPC attribute got replaced by PunRPC. Search and replace your code for [RPC] and replace it with [PunRPC] (in JS: @RPC and @PunRPC). The change is necessary, because the RPC attribute is obsolete in Unity 5.1 and that causes a large amount of warnings at compile time. The new PunRPC must be used in all versions of Unity (including 4.x), starting with this PUN version.

    Note:
    It seems Unity 5.1 has a bug exporting PUN+ to iOS. Some classes needed for Best Region pinging are missing in the export. The error is reported (Case 704938) and hopefully solved in a patch release.
    PUN+ exports fine in 5.0.2, for example. Also, PUN Free could be an alternative for you in Unity 5 (as the licensing for Unity mobile exports no longer excludes C# sockets).
     
  12. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    v1.60 (30. July 2015)
    Added: PhotonNetwork.EnableLobbyStatistics to enable/request statistics about lobbies and .LobbyStatistics as list of lobbies (available while on the Master Server). The list of lobbies is provided as a list of TypedLobbyInfo per lobby, which wraps room- and player-count per lobby (so you can find the active ones).
    Added: Callback OnLobbyStatisticsUpdate(). Implement this to be notified when new lobby statistics become available (to update your UI, etc).
    Added: PhotonNetwork.QuickResends, which controls a new feature. For reliable messages that got lost, the first few repeats can be done quicker. This improves connection reliability and reduces gaps in case of loss. Only up to 3 resends can be quick. Read the doc!
    Changed: Some PhotonNetwork fields that didn't have to be public are now internal, as intended.
    Updated: Api reference for PhotonNetwork.playerName, .SendMonoMessageTargetType and .automaticallySyncScene. Also for enum CloudRegionCode and ServerConnection and class WebRpcResponse.
    Changed: PhotonNetwork.gameVersion is now a auto-property field (and no longer sets a private field).
    Internal: Removed NetworkingPeer.mAppVersion.
    Changed: Some "per project" settings are now being moved into the PhotonServerSettings file. Currently, this can be used to set: Auto-Join Lobby, Enable Lobby Stats. Feedback welcome.
    Changed: Order of updating internal values when joining a room. The actor list is now updated before we do callbacks. This cleans up a reference to our local "dummy" player before we do the "joined" callback.
    Fixed: The inspector no longer attempts to update a PhotonView "observed" field to a list while the game is running. This led to ArgumentOutOfRange exceptions (while inspecting at runtime).
    Changed: The ChatGui class now contains a Instance field, which you could use from other scripts. It's supposed to be a singleton and to persist across loading levels (which is why it will apply DontDestroyOnLoad() to it's GameObject).
    Changed: ChatGui now also disconnects when it's GameObject gets destroyed (OnDestroyed()).
    Fixed: ConnectUsingSettings, ConnectToBestCloudServer and ConnectToRegion will only work while the client is not connected. In doubt, use Disconnect() first.
    Changed: When the PhotonHandler gets destroyed, it now cleans up the background thread which usually keeps the connection. This hopefully avoids rare freezes of the Unity Editor when closing.
    Changed: When switching the protocol, the networkingPeer is being replaced. Now we apply the previously set disconnect timeout to the new one.
    Updated: To Photon Unity Assemblies v4.0.0.11.
    Fixed: The logical order of assigning a player number when turning on OfflineMode. The callback OnConnectedToMaster be done with PhotonPlayer.ID being -1 but when you join or create a room, the client's PhotonPlayer.ID will be 1 in the callbacks.
    Changed: WebGL WebSocket.jslib. The socket.onmessage is now using an arraybuffer to read messages. This should be leaner and is a workaround for infrequent long read-times in Chrome.
    Skipped: v1.59 of PUN (used internally)
    Chat API:
    Added: IChatClientListener.DebugReturn(). This is a breaking change, if you use the interface. Photon lib and chat client log via this method (no logging to console by default).
    Changed: ChatClient.CustomAuthenticationValues is now .AuthValues. You can use those values to identify a user, even if you don't setup an external, custom authentication service.
    Changed: ChatClient.UserId no longer directly stores the id but puts it into AuthValues. This means, the UserId could also be set via setting AuthValues.
    Changed: The API of AuthenticationValues. There is now the UserId and AddAuthParameter() replaces the less general SetAuthParameters() (which only set specific key/values).
    Note: All users should have a UserId. You can set chatClient.UserId before you connect, or you can set the AuthenticationValues in Connect(..., authValues) to set a UserId.
    Added: ChatChannel.ToStringMessages(), which gets all messages in a single string, line by line. The format is "Sender:Message".
    Added: ChatClient.TryGetChannel() to find a channel only by name, no matter if public or private.
     
  13. mentolatux

    mentolatux

    Joined:
    Nov 2, 2014
    Posts:
    240
    i need help from developer pun+ , i just buy this wanterfull assets for my game based on fps kit 2.0 and i need to change server region in game , playerss in game change server from usa to europe and revers depend where the players live, i dont have option to change this, i need a script or prefab to put on scene
     
  14. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
  15. mentolatux

    mentolatux

    Joined:
    Nov 2, 2014
    Posts:
    240
    i need a script to load a scene with change server region in android game by player, i know to change server region in unity as developer , plzz help
     
  16. claytoncurmi

    claytoncurmi

    Joined:
    Jul 6, 2010
    Posts:
    168
    @tobiass

    I'm having trouble updating the master client ID. I'm currently using the Photon Server SDK v3.4.30.9719. I modified the Game.cs script so that upon construction of this class, a process that launches Unity is also created. So whenever a client (for this scenario assume this is player A) creates a new room, the server automatically launches a special Unity build and tries to connect to the same room (this will be player B). Upon successful connection, player A (which currently is the master client) sets player B as the master client. At this stage the server is set as the master client and player A can communicate with it without any issues. However as soon as another client comes into play (this will be player C), problems start occurring. Upon further inspection I managed to identify that the master client is not being propagated to the new clients once they enter the room (player C still has player A as master client rather than player B, i.e. the server). The property I'm referring to is PhotonNetwork.room.masterClientId

    I've read in this thread http://forum.unity3d.com/threads/photon-pun.204343/page-2#post-2134235 that you fixed this;

    Master Client selection for non-cloud servers (was broken in v1.52 only). If the new features are not present on the server, we now use the old client-side workflow. Photon OnPremise is still v3.x and the "Server Side Master Client" feature requires Photon v4. The public cloud servers support this feature already.
    This also explains why when connecting directly to the cloud, the same code works without any issues, but with the on premise server I'm having problems. If that is the case, from where can I get Photon Server v4?

    Another question that I would like to ask is whether I can update the master client ID directly from the server SDK. If possible could you indicate which files should I check as I couldn't find any hints re the MasterClient (I'm looking at the LoadBalancing app).

    Regards,
    Clayton
     
  17. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    @claytoncurmi:
    The Server Side Master Client feature is relatively new, so you definitely need a new server SDK for it.
    The v4 SDK is still under development but if you mail us to developer@exitgames.com, we can send you a version to use.
    I don't know the details how to set the Master Client ID in the server logic, but I am sure there is a way. The LoadBalancing App's Room class will be the place to look into. Please copy and paste that question to your mail and my colleagues will let you know.
     
  18. claytoncurmi

    claytoncurmi

    Joined:
    Jul 6, 2010
    Posts:
    168
    Thanks @tobiass. Email sent right now!
     
  19. Humor

    Humor

    Joined:
    Dec 28, 2015
    Posts:
    1
    When I run the VoiceDemo .Sometimes I can not connect to the server.
    here is the log.
    SwitchToProtocol: Udp PhotonNetwork.connected: False
    Cause: DisconnectByClientTimeout
    I use the free version
     
  20. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    This happens when the client doesn't get acknowledgements from the server for a while.
    We're not aware of general issues with the cloud. Is your network OK? Which region do you connect to?