Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Photon Unity Networking

Discussion in 'Connected Games' started by tobiass, Aug 23, 2011.

  1. Elendarys

    Elendarys

    Joined:
    Sep 14, 2017
    Posts:
    17
    Using photon for persistent worlds, would I need multiple photon servers or would it suffice to use rooms?
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,165
    @vsnry: You only pay for the CCU once, no matter if you use the Photon Cloud or Photon Server.
    Using the Photon Server enables you to run "as is" (similar to the Photon Cloud), you can add logic or rewrite the stock solution almost entirely.
     
  3. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,159
    @tobiass Hey I have a issue with Photon Chat.
    When I subscribe to a channel "Test" and then change scenes and then unsubscribe to channel "Test". It errors and says I wasn't subscribed to channel "Test".

    • If I unsubscribe to channel "Test" while staying on the same scene it works fine.
    • The chat server stays connected.
    • The Game Object that the IChatClientListener is attached to is set to don't destroy on scene change.
    • When I change scenes it doesn't run the call back OnUnsubscribed for channel "Test". So its not saying it ever Unsubscribes from that channel or it does but never calls the call back.
    • I can subscribe to a new channel with no issue on the next scene.


    After debugging all this. I also realized when I subscribe to a channel that has already been subscribed it doesn't say error saying already subscribed to that channel? Is that the attended behavior? If so then what is going on. Is it creating two channels with the same name or is it just over riding it.
    If it just over rides it than that is fine i can just keep track of the channels the user subscribes too.

    But this unsubscribe thing im not sure whats going on here.
    Based on my tests it seems it just deletes all channels when the change changes and doens't run the call back OnUnsubscribed for them.

    On a side note. Its been about 6 months since I've messed with the chat networking on my game but it does seem like I remember it not allowing me to subscribe to a channel that is already subscribed too. so idk.

    using Unity 2018.2.18
     
  4. o8que

    o8que

    Joined:
    Oct 13, 2018
    Posts:
    1
    Hello,
    I found an issue with the calculation of lag in Lag Compensation.
    Code (CSharp):
    1. float lag = Mathf.Abs((float) (PhotonNetwork.Time - info.timestamp));
    It wasn't correctly considered that PhotonNetwork.Time value will wrap around.
    If PhotonNetwork.Time is 0 and info.timestamp is 4294967, "lag" will be 4294967!

    So I'm currently using PhotonNetwork.ServerTimestamp to calculate lag to avoid this issue.
    Code (CSharp):
    1. float lag = unchecked(PhotonNetwork.ServerTimestamp - info.timeInt) / 1000f; // changed info.timeInt from private to public
    I hope this helps.
     
  5. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,165
    @o8que: Good find. Thanks! We will put this in the next update.
    @Shadowing: I asked a colleague to check this out.
     
  6. JohnTube

    JohnTube

    Joined:
    Sep 29, 2014
    Posts:
    59
    Hi @Shadowing

    Thank you for choosing Photon!

    What is the Photon Chat API version you use?
    Check the Photon3Unity3.dll version or if it's from PUN check the PUN version.

    Yes, it is the intended or expected behaviour.
    The server does not return an error in this case. Nothing changes, the client stays subscribed to the same channel.
    We could improve this by triggering an error or a warning on the client side.
    If the scene loading delay is big enough, probably the client got disconnected, did you check the OnDisconnected callback?
     
    Shadowing likes this.
  7. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,159
    Hey @JohnTube
    Seems I have 3 Photon3Unity3D.dll files
    Been wanting to remove Photon networking package from my project cause I only use photon chat.
    Two of the files are product version 4.1.1.20 and the other one is Product Version 4.0.0.12

    ya there was no chat disconnect. Keep in mind i was able to subscribe to a channel as well as talk in chat etc.. Chat fully operational on next scene.
    Actually I just realized im calling Unsubscribe before changing the scene. There is a 8 second wait before the Change Scene function is called. (For visual effect reasons)
    so thats odd hmm. Its not happening on the same frame then.
    Almost tells me it has nothing to do with the scene changing now.

    OnDisconnected doesn't get called. I have a debug.Log on that also it would kick me back to login scene etc. I just tested and doubled checked that.


    I'll do a couple more tests. Help rule out scene changing or not.
     
    JohnTube likes this.
  8. sob_unity

    sob_unity

    Joined:
    Nov 21, 2018
    Posts:
    1
  9. JohnTube

    JohnTube

    Joined:
    Sep 29, 2014
    Posts:
    59
    Hi @sob_unity,

    Thank you for choosing Photon!

    You can use PUN+'s 100CCU with PUN2.
    So you can purchase PUN+ Classic, redeem the Unity Invoice Nr. here for one AppId then download PUN2 free and use that AppId.
    There is no difference between PUN2 and PUN2+ other than the 100CCU.
     
  10. jeffersoncosta

    jeffersoncosta

    Joined:
    Aug 11, 2018
    Posts:
    4
    I'm using the Corgi Engine and in previous versions of Photon i was able to add the MoreMountains.CorgiEngine namespace on the PhotonNetwork class, but now it does not work anymore . upload_2018-12-27_14-42-38.png
     
  11. DavidSWu

    DavidSWu

    Joined:
    Jun 20, 2016
    Posts:
    87
    I am trying to decide whether or not to upgrade to 2.0. We have a relatively large product.
    What are the benefits of 2.0?
    Benefits:
    - Seems that simplifying the lobby system is a plus.
    - Seems like callbacks *might* be more efficient
    - Latest updates
    - Not using a deprecated system
    - Performance improvements (?)
    Costs:
    - All sorts of arbitrary name changes (dear god, why?)
    - API functionality changes will require refactoring
    - Potentially less stable than PUN classic as it is still relatively early.

    Am I missing anything?

    Thanks!

    David Wu
     
  12. banksazero

    banksazero

    Joined:
    May 8, 2015
    Posts:
    65
    Hi
    I wonder if I'd like to use login system for keeping player's stat and items what I need to know and do?
     
  13. JohnTube

    JohnTube

    Joined:
    Sep 29, 2014
    Posts:
    59
    Hi @jeffersoncosta,

    Thank you for choosing Photon!

    I think you are probably using a Unity 2017.3+ (or higher/newer) which supports asmdef.
    If you want to modify PUN2 code you will need to reference any external assemblies in its respective asmdef file.
    Read this post on our forum here.
     
  14. SteveRyu

    SteveRyu

    Joined:
    Apr 9, 2014
    Posts:
    121
    Hi,
    Is there any way to cancel the coupon use?
    I used it on the wrong one. Chat server, not realtime one.
    I already sent email to support team and posted the same question on photon forum but there's no answer so I post it here.
    Please help me, thanks.
     
  15. JohnTube

    JohnTube

    Joined:
    Sep 29, 2014
    Posts:
    59
    I replied to your forum post here.
     
  16. JohnTube

    JohnTube

    Joined:
    Sep 29, 2014
    Posts:
    59
    Hi @banksazero,

    Thank you for choosing Photon!
    We recommend PlayFab.
    You can integrate their services with Photon apps.
     
  17. neodotca

    neodotca

    Joined:
    Feb 20, 2016
    Posts:
    120
    Is it possible to make one multiplayer battle Royale game, taking place in different maps/levels at the same time. Instead of having one big open world map, the action takes place in many smaller levels, where the players can move from a level to another until there's only one standing?
     
  18. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,165
    You could split the world into multiple scenes and even into multiple "rooms" for the networking but then you will have to think about handling the edges. If players can run along an invisible edge, they have to load and unload scenes, depending on which side they happen to be from frame to frame? Also, if you don't load the scene next to the active one, you may be able to see players, which should hidden by obstacles (which you didn't load yet)?
     
  19. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,170
    You could make players in the 'other' scene invisible also, much like the phasing in WoW. That's how I handle multiple scenes (maps) in my RPG.
     
  20. neodotca

    neodotca

    Joined:
    Feb 20, 2016
    Posts:
    120
    Thank you for your answers, I'm just starting to learn about multiplayer. I'm not talking about splitting a world in multiple scenes or rooms, I'm talking about complete separate levels, just like an adventure game where your player will move to the next level...loading a new level using "persistence". You won't be able to see the players that are not in the level you are in because they are just not in your level. In short, a regular multiplayer game, but not only on one level, but complete separate levels. Thanks!
     
  21. JamesGartland

    JamesGartland

    Joined:
    Jun 1, 2017
    Posts:
    8
    Hello, I'm new to Photon and I'm getting an annoying Editor bug with PUN 2 and Unity 2018.3.

    After Playing the game once in editor I can no longer add components to. GameObjects via the 'Add Component' button in the Inspector window. The only workaround I've found so far is to close and restart Unity, but this means I have to restart to add components after every single play test.

    Clicking the 'Add Component' button gives me this error

    Code (CSharp):
    1. ArgumentException: An element with the same key already exists in the dictionary.
    2. System.Collections.Generic.Dictionary`2[System.String,System.String].Add (System.String key, System.String value) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:404)
    3. UnityEditor.AdvancedDropdown.AddComponentDataSource.GetMenuDictionary () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/AddComponent/AddComponentDataSource.cs:70)
    4. UnityEditor.AdvancedDropdown.AddComponentDataSource.RebuildTree () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/AddComponent/AddComponentDataSource.cs:17)
    5. UnityEditor.AdvancedDropdown.AddComponentDataSource.FetchData () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/AddComponent/AddComponentDataSource.cs:10)
    6. UnityEditor.AdvancedDropdown.AdvancedDropdownDataSource.ReloadData () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/AdvancedDropdown/AdvancedDropdownDataSource.cs:22)
    7. UnityEditor.AdvancedDropdown.AdvancedDropdownWindow.OnDirtyList () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/AdvancedDropdown/AdvancedDropdownWindow.cs:202)
    8. UnityEditor.AdvancedDropdown.AdvancedDropdownWindow.Init (Rect buttonRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/AdvancedDropdown/AdvancedDropdownWindow.cs:95)
    9. UnityEditor.AdvancedDropdown.AdvancedDropdownWindow.CreateAndInit[AddComponentWindow] (Rect rect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/AdvancedDropdown/AdvancedDropdownWindow.cs:79)
    10. UnityEditor.AdvancedDropdown.AddComponentWindow.Show (Rect rect, UnityEngine.GameObject[] gos) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/AddComponent/AddComponentWindow.cs:68)
    11. UnityEditor.InspectorWindow.AddComponentButton (UnityEditor.Editor[] editors) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1811)
    12. UnityEditor.InspectorWindow.OnGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:680)
    13. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
    14. Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    15. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
    16. System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
    17. UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:342)
    18. UnityEditor.HostView.Invoke (System.String methodName) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:336)
    19. UnityEditor.HostView.InvokeOnGUI (Rect onGUIPosition, Rect viewRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:302)
    20.  
     
  22. JohnTube

    JohnTube

    Joined:
    Sep 29, 2014
    Posts:
    59
    Hi @JamesGartland,
    Thank you for choosing Photon!
    Could you try my suggestion here.
     
  23. rubble1

    rubble1

    Joined:
    Apr 25, 2010
    Posts:
    75
    Hi,

    I'm having some problems using PUN.
    I'm using a character system that can't be enabled on the remote, due to some animator settings (Third Person Motion Controller). I need it to equip a weapon over the network.

    I've created a script that gets the name, transform and parent of this object and is supposed to recreate it across the network. Everything is working fine on the local view, and all I need is for it to instantiate the object for the remote player.

    As a side note, when I was working in PUN classic a while back, I could playtest a connected game in the Unity editor, which made things a lot easier. Is this different in PUN2 or am I doing something wrong?

    My game works this way: I have a game manager script instantiating the player (similar to the Asteroids demo). This player has the script mentioned above that gathers local info (mentioned above), stores them in a local variable in my first function (let's call it "SendPhotonEquip"). This script is observed by that player's photon view.

    Having gathered all the info on the item equipped, it calls up a PunRPC function that will instantiate an item on the remote player.

    Code (CSharp):
    1.             photonView.RPC("PhotonEquip", RpcTarget.OthersBuffered);
    I then send it off to the actual function that will create the item. This function tests to see if the view is local or remote, and if it's remote it will instantiate the object:

    Code (CSharp):
    1.     [PunRPC]
    2.     public void PhotonEquip()
    3.     {   //This actually creates the items on the remote player.
    4.  
    5.  
    6.         if (rWeaponTemp != null)
    7.         {
    8.  
    9.             GameObject rWeaponObject = Resources.Load<GameObject>(rPath);
    10.             PhotonView rWeaponID = rWeaponObject.GetPhotonView();
    11.             rWeaponID = photonView;
    12.             (PhotonNetwork.Instantiate(rPath, rWeaponPosTemp, rWeaponRotTemp) as GameObject).transform.parent = rWeaponParent.transform;
    13.  
    14.             return;
    15.         }
    16.  
    17.  
    18.     }
    Again, if I use "AllBuffered" when calling it up, it does instantiate about two extra versions of the item on my local view (so something's working), but when I use "OthersBuffered", I don't see the remote player's item.

    I've tried different things. For example, getting rid of the if (photonView.IsMine) statement in the second function, and even placing a check on the first function. Neither work.

    I would really welcome any advice or suggestions. Thanks.
     
  24. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,165
    You're multiplying the instanced object by letting everyone else network-instantiate the GO (within the RPC).
    You can either PhotonNetwork.Instantiate() something or use a RPC to do about the same by (locally only) instantiating the GO.
    I guess this causes the issues without going into deeper analysis of it.

    PUN 2 runs in the Editor just like PUN Classic does. So a build and an Editor can be used to test.
    Make sure the Editor and build are connected to the same region and don't run ConnectAndJoinRandom at (about) the same time. During development, this script may miss the other instance's room and end up in a separate one.
     
    rubble1 likes this.
  25. rubble1

    rubble1

    Joined:
    Apr 25, 2010
    Posts:
    75
    @tobiass, thank you! that really helps.

    Following your suggestion, I do now have it appearing for the remote client, but I think it still also instantiates at least 2 extras on the local.
    How do I get the object to only appear for the remote player?

    Also, on the position of the item.
    Once this was working, I did notice it wasn't really attached to the player's hand, so I put a Transform view on it, and it did move with the player, but had a sort of a lag to it. It does need the transform view, right? I can't just rely on the parent to move it around? I'm playing around with it to see which behaves better, the Photon Transform View or the Transform Classic view, but can't really tell yet.

    Anyway, there are still some things to be worked out, but I can begin to see now. Thank you so much for the help.
     
    Last edited: Jan 12, 2019
  26. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,165
    Not knowing your case I wonder:
    Why do you network-instantiate something that just one of the clients would see and care about?
    It doesn't have to be networked, if not everyone sees it anyways. If there is no local representation of said networked object, only one client knows about it. Then it could be fully local.

    If you want (e.g.) your hands to be shown to everyone, you would network-instantiate them once and that's it. Everyone in the room will create the representation. When the hands get instantiated, they Awake. Put a script on them and can check "isMine" to change how the representation looks like (locally, you could use another look than remotely).
    Check out the basics tutorial and actually code along as you read it. This should help, I hope.


    > but had a sort of a lag to it.

    Yes. That is simply lag.

    > I can't just rely on the parent to move it around?

    Not magically, no. If the parent has a PhotonView, it may gather and include the info of the attached child nodes and send it along with it's own info.
     
    rubble1 likes this.
  27. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    718
    Hi Tobiass

    We have a page on our game where the user can select which region they want to play in. This page also shows the pings of each region. (We get the ping using RegionPinger, pinging all regions manually).

    It would be awesome to be able to display the amount of activity in the region. A player count would be ideal, even if rough, and we could either display this number as an approximate or map different player count number ranges to different sprites to give an indicator of 'activeness' (ie low activity - 1 person silhouette, high activity = 10 people silhouettes, etc). The point is it doesnt have to be accurate :)

    Is this possible?
     
  28. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,165
    Getting stats about the regions' activity is not built-in but the idea has been around for a while.
    The count of players and rooms is available to any client on the Master.
    You could create a service that connects to each region in intervals and fetches the Application Stats from each master. Clients could get this from your service.
     
    Prodigga likes this.
  29. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,159
    @tobiass any chance you guys can build a serverside software that runs on linux build of Unity?

    Or are you guys getting close to releasing a linux server yet? Been waiting a long time :(
    Sucks your server side software is only Windows Server :(

    Can't you just build it using Python?
     
  30. EthanHooper1023

    EthanHooper1023

    Joined:
    Jan 19, 2017
    Posts:
    3
    Hello,
    I'm trying to add my current room to a list to display in the master lobby later, but when I try to add my current room to a list of type RoomInfo it gives me a huge error.

    RPC to add to list:
    Code (CSharp):
    1. public PhotonView pv;
    2.  
    3.     void Start()
    4.     {
    5.         pv.RPC("AddRoom", RpcTarget.AllBuffered, new object[] { PhotonNetwork.CurrentRoom });
    6.     }
    PunRpc Method:
    Code (CSharp):
    1. [PunRPC]
    2.     public void AddRoom(RoomInfo room) {
    3.         punConnect.GetRoomList().Add(room);
    4.         Debug.Log("Server Added Room: " + room.Name);
    5.     }
    Exception: Write failed. Custom type not found: Photon.Realtime.Room
    ExitGames.Client.Photon.Protocol18.WriteCustomType (ExitGames.Client.Photon.StreamBuffer stream, System.Object value, Boolean writeType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol18Write.cs:685)
    ExitGames.Client.Photon.Protocol18.Write (ExitGames.Client.Photon.StreamBuffer stream, System.Object value, GpType gpType, Boolean writeType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol18Write.cs:46)
    ExitGames.Client.Photon.Protocol18.Write (ExitGames.Client.Photon.StreamBuffer stream, System.Object value, Boolean writeType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol18Write.cs:25)
    ExitGames.Client.Photon.Protocol18.WriteObjectArray (ExitGames.Client.Photon.StreamBuffer stream, IList array, Boolean writeType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol18Write.cs:602)
    ExitGames.Client.Photon.Protocol18.Write (ExitGames.Client.Photon.StreamBuffer stream, System.Object value, GpType gpType, Boolean writeType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol18Write.cs:106)
    ExitGames.Client.Photon.Protocol18.Write (ExitGames.Client.Photon.StreamBuffer stream, System.Object value, Boolean writeType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol18Write.cs:25)
    ExitGames.Client.Photon.Protocol18.WriteHashtable (ExitGames.Client.Photon.StreamBuffer stream, System.Object value, Boolean writeType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol18Write.cs:368)
    ExitGames.Client.Photon.Protocol18.Write (ExitGames.Client.Photon.StreamBuffer stream, System.Object value, GpType gpType, Boolean writeType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol18Write.cs:79)
    ExitGames.Client.Photon.Protocol18.Write (ExitGames.Client.Photon.StreamBuffer stream, System.Object value, Boolean writeType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol18Write.cs:25)
    ExitGames.Client.Photon.Protocol18.WriteParameterTable (ExitGames.Client.Photon.StreamBuffer stream, System.Collections.Generic.Dictionary`2 parameters) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol18Write.cs:167)
    ExitGames.Client.Photon.Protocol18.SerializeOperationRequest (ExitGames.Client.Photon.StreamBuffer stream, Byte operationCode, System.Collections.Generic.Dictionary`2 parameters, Boolean setType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol18Write.cs:186)
    ExitGames.Client.Photon.EnetPeer.SerializeOperationToMessage (Byte opCode, System.Collections.Generic.Dictionary`2 parameters, EgMessageType messageType, Boolean encrypt) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:1138)
    ExitGames.Client.Photon.EnetPeer.EnqueueOperation (System.Collections.Generic.Dictionary`2 parameters, Byte opCode, SendOptions sendParams, EgMessageType messageType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:974)
    ExitGames.Client.Photon.PhotonPeer.SendOperation (Byte operationCode, System.Collections.Generic.Dictionary`2 operationParameters, SendOptions sendOptions) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1496)
    Photon.Realtime.LoadBalancingPeer.OpRaiseEvent (Byte eventCode, System.Object customEventContent, Photon.Realtime.RaiseEventOptions raiseEventOptions, SendOptions sendOptions) (at Assets/Photon/PhotonRealtime/Code/LoadbalancingPeer.cs:870)
    Photon.Realtime.LoadBalancingClient.OpRaiseEvent (Byte eventCode, System.Object customEventContent, Photon.Realtime.RaiseEventOptions raiseEventOptions, SendOptions sendOptions) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:1598)
    Photon.Pun.PhotonNetwork.RaiseEventInternal (Byte eventCode, System.Object eventContent, Photon.Realtime.RaiseEventOptions raiseEventOptions, SendOptions sendOptions) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2141)
    Photon.Pun.PhotonNetwork.RPC (Photon.Pun.PhotonView view, System.String methodName, RpcTarget target, Photon.Realtime.Player player, Boolean encrypt, System.Object[] parameters) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:1242)
    Photon.Pun.PhotonNetwork.RPC (Photon.Pun.PhotonView view, System.String methodName, RpcTarget target, Boolean encrypt, System.Object[] parameters) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2682)
    Photon.Pun.PhotonView.RPC (System.String methodName, RpcTarget
     
  31. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,165
    @Shadowing: We're not there yet. Would you just run the pre-built Photon "LoadBalancing" or would you want to run custom logic, too?

    @EthanHooper1023: The error tells you that the Room (or RoomInfo) class can't be serialized.
    RPCs are only sent within the room you're active in. So there is no use to send it with an RPC, actually.
    We've got lobbies on the Master Server, should you want to fetch the list of rooms. Any other sort of room listing must be done externally.
    What's the plan?
     
  32. Appminis

    Appminis

    Joined:
    Apr 12, 2014
    Posts:
    141
    How do you prevent cheating with PUN? And aren't there issues with a player hosting a game if there are lots of other players? Would worry about latency. Can competitive multiplayer comes use PUN without issue?
     
  33. rubble1

    rubble1

    Joined:
    Apr 25, 2010
    Posts:
    75
    I see.
    It's almost working now.
    I'm just trying to literally copy a locally spawned object over to the remote client. I think the problem I was having is that I wasn't syncing all the variables I needed in OnPhotonSerialize

    Once I fixed that, I did get some errors. I can't really sync hierarchy information, is that right? Is there any suggestion for how I could pass the parent information to the remote player?
     
  34. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,165
    @Appminis: PUN is not really built with competitive multiplayer in mind. Aside from some sort of cheat protection, you probably need replays and an option to check results on the server-side, etc.. Have a look at Quantum.

    @rubble1: You could probably sync hierarchy information but it's up to you how you do. Keep in mind that potentially the clients have differing views of the world and that not all hierarchy exists at all clients at the same time.
    I would not use a complex hierarchy for networked objects but to organize things somewhat, you could create top-level objects as potential parents, then pass their name. Or organize by type of prefab that's being network instantiated.
     
  35. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    251
    It seems that Quantum is only for 2D games which rules it out for most people.
     
  36. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    718
    2D simulation doesn't mean 2D presentation. Brawl Stars for example could easily be simulated in 2D, but is presented as 3D.

    Smoke and mirrors.

    I wish I could try Quantum but the cost of entry for an unknown product with unknown capabilities is too high. $1000 USD per month, minimum 3 months for the first 3 months, then month to month. $3k is too steep for something I just want to "mess around with" to see if it is appropriate for our projects. That's $4.1k AUD, or 4 months rent for me! :p
     
  37. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    251
    I had to look it up but Brawl Stars (was unfamiliar with the title) looks to be a simple isometric game, not a 3D game.

    I do agree that the price is not indie or even assessment friendly, clearly aimed at larger studios only. Even then you would want to be sure before contemplating it as it could end up being an expensive failed test.
     
  38. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    718
    Brawl stars started out as a 2d isometric game, but is now rendered in 'real' 3D (not pre-rendered graphics), which was my point - the game can look 3D, the simulation doesn't have to me. The '3D update' come out just recently, so the screenshots online are probably outdated. You should grab the game for yourself and check it out.
     
  39. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    251
    hmmm. Just looked... Still an isometric game just now rendered from models rather than tile sets. To me, not really a 3D game. Regardless, my point was that Quantum is of no use to a 3D game but if you are making a 2D game and even a 2.5D (isometric) game then maybe it can be a of use as that is what it is designed for / limited to currently.
     
  40. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,165
    We submitted PUN v2.6 to the store. We hope this version fixes the problems with the new prefab workflow (2018.3) and lots of other smaller and bigger issues. Here's the full list:

    v2.6 (25th January 2019)
    Fixed: Offline custom properties are now set even if ExpectedProperties is set, as there is only one source for setting properties when in offline mode.
    Fixed: Switching Offline mode off now properly cleans up room content.
    Fixed: Infinite for-loop when enabling all Interest Groups by using new byte[0] as parameter for the SetInterestGroups function.
    Fixed: The PhotonView attribute AddComponentMenu could not have a shortcut (in 2018.3) for unknown reasons. It was causing compile errors in some cases, so the shortcut (&v) is gone.
    Fixed: Rpc list was not showing in the ServerSettings Inspector.
    Fixed: Inspector for ServerSettings no longer closes due to recompile.
    Added: Tooltips for all fields in the Photon Server Settings. Each entry is now at least somewhat explained. More in the docs.
    Changed: PhotonNetwork.WebRPC can set AuthCookie webflag, which is used for WebHooks.
    Changed: PhotonNetwork.CurrentLobby and LoadBalancingClient.CurrentLobby are now readonly. The lobby must be defined by joining one or via the parameter when creating rooms. As before: You don't have to join a lobby to do matchmaking via a lobby.
    Changed: SupportLogger now makes use of the new ServerIpAddress value in the PhotonPeer.
    Changed: Added a local timestamp to the SupportLogger: it now logs [Time.unscaledTime] in front of each log.
    Changed: SupportLogger will also log the "basics" when it got the RegionsList from the Name Server (and it now logs the NS IP-address).
    Changed: The log output when Join/Create failed. Now it also logs the State (which is the primary value for IsConnectedAndReady). Better for debugging.
    Changed: PhotonNetwork.time is now cached per frame (based on Unity's frameCount value). This applies the same time-value for the whole frame, no matter when Update() gets called on a specific object. This might avoid some judder when syncing objects.
    Changed: The property "timestamp" is obsolete (as name) in PhotonMessageInfo. There is now a SentServerTimestamp integer and a SentServerTime double. It makes sense to use the integer to calculate delta-times in milliseconds.
    Added: Callback OnDisconnected() to connection-exception handling for "Exception in Receive". Also for: "Max CCU Reached" (probably not used).
    Added: Note in reference doc, that "Exception" for receive is typical if you connect a local Photon on Windows but the server isn't running/available.
    Fixed: SetInterestGroup() for Offline mode. If offline, it can simply skip the call to OpChangeGroups and avoid some log spamming.
    Added: ServerSettings now let you open the dashboard directly for each types of ids, and let you open the whiteList region editor as well.
    Fixed: PhotonEditorUtils.IsPrefab() is fixed for 2018.3 onwards, it now takes in consideration both assets and prefab editing stage when checking.
    Changed: Setting PhotonNetwork.PrefabPool to null now logs a warning and default to the DefaultPool class.
    Fixed: Problems with "Best Region" selection on Nintendo Switch. Best Region now works, even if all available Photon Cloud regions need to be pinged.
    Internal: PingMono class now keeps one Socket instance until discarded.
    Internal: PingMono uses Socket.Poll() now, instead of .Available (which might also be the cause why this is Switch compatible now).
    Internal: PUN now sends PhotonView-updates via a re-used List<object>. A second list was added to the PhotonView, so they can be used alternating and without copying values before sending them.
    Changed: ExecuteRpc() to not always create argument- and argument-type-list. This is a minor optimization.
    Changed: ExecuteRpc() check of arguments versus a method's parameters.
    Changed: RPC() to re-use the event-content Hashtable (and clear it instead of re-creating it every time).
    Updated: Photon3Unity3d.dll library to rev4954.
     
  41. TRuoss

    TRuoss

    Joined:
    Dec 5, 2012
    Posts:
    81
    Hi @tobiass

    I tried pun 2 today and do not get OnLeftLobby() after PhotonNetwork.CreateRoom(roomName). Is this intended? because on OnCreatedRoom(), PhotonNetwork.InLobby is false. So it left the lobby without calling OnLeftLobby.

    I can provide a tiny project if needed
     
  42. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,165
    @TRuoss: Yes, in this case, leaving the lobby is implicit. Good point, however. Right now, OnLeftLobby is only called when you deliberately leave the lobby.

    Is it a problem?
     
  43. TRuoss

    TRuoss

    Joined:
    Dec 5, 2012
    Posts:
    81
    The classic pun did call OnLeftLobby. It would make sense for me that when the system leaves the lobby it would rise that event. I use it for debug and show or hide UI gameobjects a lot. I miss it. It feels like breaking the connection flow.

    Pun Classic:
    ConnectedToMaster -> JoiningLobby -> JoinedLobby -> LeavingLobby -> LeftLobby -> Joining/CreatingRoom -> JoinedRoom -> LeftRoom -> ConnectedToMaster

    Pun 2:
    ConnectedToMaster -> JoinedLobby -> Joining/CreatingRoom -> JoinedRoom -> LeftRoom -> ConnectedToMaster

    Is a bit confusing.

    Another thing that changed. When leaving a room the classic joined the lobby. pun 2 leaves the room and that rejoins the MasterServer, not the lobby. But this is ok form me. When I leave a game I would go to the main menu not the lobby again.

    One thing would be nice too. Detecting if the player leaves the lobby to join a room or go back to Master by observing the state changes. I could make some logic to detect if the player pressed join/create room to get that he is leaving the lobby to join a room, but it would be nice to not ask gui code in my network controller to detect what the user did.
     
  44. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,165
    @TRuoss: I found where that callback got dropped. It should be easy to add again.
    In fact, you could do it (as a workaround): Find LoadBalancingClient.OnStatusChanged and edit the case Disconnect. In there, add this before InLobby gets set to false:

    if (this.Server == ServerConnection.MasterServer && this.InLobby) this.LobbyCallbackTargets.OnLeftLobby();


    The second change is definitely deliberate. We found that several games joined the lobby without using the received lists at all. However, sending the lobby lists is a lot of traffic, so it should only be joined when needed. As you said, it's not complicated to join a lobby again, when on the Master Server.

    If you added the callback as described above, you can find out if the client is joining a game or not by checking the LoadBalancingClient.State. It's ConnectedToMasterserver, when the client simply left the lobby (and stays on the Master Server). Else, it should be DisconnectingFromMasterserver normally. Any other state is likely a complete disconnect (I didn't repro this yet).
     
  45. TRuoss

    TRuoss

    Joined:
    Dec 5, 2012
    Posts:
    81
    @tobiass thanks for the fast reply I will give it a try.
     
  46. onurerlermomend

    onurerlermomend

    Joined:
    Jan 31, 2019
    Posts:
    1
    in offline mode, PhotonNetwork.CurrentRoom.SetCustomProperties(probs); doesnt work.
     
  47. TRuoss

    TRuoss

    Joined:
    Dec 5, 2012
    Posts:
    81
    @tobiass the changes you have mentioned worked, thanks for that.

    Other Question. Is it possible to stop periodic room list updates in Lobby and use something like a refresh button? Would that save lobby traffic? I know that this is not the intentional use of PUN.

    I tried PhotonNetwork.GetCustomRoomList(TypedLobby.Default, sqlLobbyFilter); but I think that's not how it should be used ^^
     
  48. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,165
    Which version of PUN are you using? We recently fixed custom property setting for offline mode. Update, if you don't use the most up to date and let us know.

    @TRuoss: We think it's better to provide periodic updates with the changes only, than letting everyone refresh the list at will (which might end up being a higher frequency). If you let the fetched list grow old, the info will be outdated and rooms may be full or gone. A short, fresh list, on the other hand, means anyone in manual matchmaking will attempt to join the same listed rooms, which is also a race condition in busy games.

    The optimum matchmaking is our random matchmaking server side.

    PhotonNetwork.GetCustomRoomList() works for SQL Lobbies only, so the .Default won't work.
    Also see: https://doc.photonengine.com/en-us/pun/current/lobby-and-matchmaking/matchmaking-and-lobby
     
  49. DuvE

    DuvE

    Joined:
    May 22, 2016
    Posts:
    93
    Hi,

    I'm really confused with PUN2 and Bolt differences. According to your comparison documentation from this page - https://doc.photonengine.com/en-us/pun/v2/reference/pun-vs-bolt Photon PUN2 is using "true" dedicated servers but still have Master Clients with some authorities. And the Photon Bolt games hosted completely on the Client side, so if the host disconnects, all other players will disconnect too. However, in Photon Bolt documentation there are four different Bolt "modes", p2p, Dedicated Server, Listening Server, and LAN. In this page also said, that if you choose Dedicated Photon Bolt, you need to actually host it on your own hosting.

    So here are my questions:

    1. What is the difference with Bolt using Dedicated Server and PUN2 (with also using a dedicated server on Photon Cloud)? Also, if I need to host Bolt Dedicated on my own server, why I need to pay per CCU actually, I'm using my own hosting but not Photon Cloud, right? Also, why this Dedicated Server cannot be hosted on Photon Cloud instead?

    2. You marketing Bolt as a "Perfect" solution for FPS/Battle Royale/Action type of games, but its games hosted on Clients side, isn't this actually very bad for FPS? Or Bolt only good for Action game if it is hosted on my own hosting with a dedicated server?

    3. If PUN2 using dedicated servers too, why it is worse the Bolt for Action games?

    About my game and the last question about CCU. The game will be 80% singleplayer and 20% multiplayer, actually, the whole multiplayer setup is very similar to Dark Souls kind of games. Imagine 1000 player playing the game simultaneously, but only 50 of them activated a special item which allows them to duel with each other (from this 50 players groud). Let's say, every 1 minute the system(matchmaking system probably, I guess) assign two players to begin a duel from this 50 players of course. Other 950 players playing the game in single player (offline mode), until they found and activate this special item. So, in my case, there is 50 CCU or 1000 CCU? It is great, if I will be able to stay at 50 CCU, so 950 other players will play with any Photon networking turned off until activation of a special item.
     
  50. onurerler

    onurerler

    Joined:
    Apr 10, 2013
    Posts:
    8
    my pun version is 2.6

    You removed codes below from room.cs / setCustomProperties method if is offline

    this.CustomProperties.Merge(customProps);
    this.CustomProperties.StripKeysWithNullValues();


    ///////////////////////////////
    In 2.5 was
    //////////////////////////////
    public virtual void SetCustomProperties(Hashtable propertiesToSet, Hashtable expectedProperties = null, WebFlags webFlags = null)
    {
    Hashtable customProps = propertiesToSet.StripToStringKeys() as Hashtable;

    // merge (and delete null-values), unless we use CAS (expected props)
    if (expectedProperties == null || expectedProperties.Count == 0)
    {
    this.CustomProperties.Merge(customProps);
    this.CustomProperties.StripKeysWithNullValues();
    }

    if (this.isOffline)
    {
    // invoking callbacks
    this.LoadBalancingClient.InRoomCallbackTargets.OnRoomPropertiesUpdate(propertiesToSet);
    }
    else
    {
    // send (sync) these new values if in online room
    this.LoadBalancingClient.LoadBalancingPeer.OpSetPropertiesOfRoom(customProps, expectedProperties, webFlags);
    }
    }

    ///////////////////////////////////////////////
    // But now
    //////////////////////////////////////////////

    public virtual void SetCustomProperties(Hashtable propertiesToSet, Hashtable expectedProperties = null, WebFlags webFlags = null)
    {
    Hashtable customProps = propertiesToSet.StripToStringKeys() as Hashtable;

    if (this.isOffline)
    {
    // invoking callbacks
    this.LoadBalancingClient.InRoomCallbackTargets.OnRoomPropertiesUpdate(propertiesToSet);
    }
    else
    {
    // merge (and delete null-values), unless we use CAS (expected props)
    if (expectedProperties == null || expectedProperties.Count == 0)
    {
    this.CustomProperties.Merge(customProps);
    this.CustomProperties.StripKeysWithNullValues();
    }

    // send (sync) these new values if in online room
    this.LoadBalancingClient.LoadBalancingPeer.OpSetPropertiesOfRoom(customProps, expectedProperties, webFlags);
    }
    }