Search Unity

Third Party Photon Unity Networking

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

  1. dilbertian

    dilbertian

    Joined:
    Aug 13, 2010
    Posts:
    74
    ***
    Well, before sending anything off to support, I gave everything one more try this morning, and can now report that all is working fine.

    Was there something you all corrected on the server which fixed this or was it some sort of data propagation issue after a new user signup?
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    dilbertian:
    Maybe you still used the Chat AppId or something.
    Unfortunately PUN apps and Photon Chat apps have different IDs at the moment. Make sure you use the correct one per project. At the bottom of each Dashboard page, you can switch between Chat, Realtime (Cloud), etc.
    The message seems a bit odd for that case. I'll have to check.

    We are not aware that there were any problems in the Cloud, as other games still worked as expected.
     
  3. thanhle

    thanhle

    Joined:
    May 2, 2013
    Posts:
    162
    my game created by use photon unity networking but
    my country connect to photon cloud ping so high
    so i want use photon server and run in my country server to connect my game
    i mean use photon unity networking connect to photon server ( located in my country ) it can work ?
    all logic game still from client , photon server just use to connect client ( like photon cloud but it in my country )
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
  5. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    Hey @tobiass thanks for adding the Ping functionality.

    Would be possible for you guys to expose the AllocateViewId for scene objects?

    For player objects I'm using custom instantiation and manually allocating their view ids Im doing this because I wanted to use PoolManager to spawn objects I want to do the same with scene objects but doesnt seem to be possible right now.
     
  6. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    There is an AllocateSceneViewIDs method in the PhotonNetwork class. You could modify it to be public to use it. This should do what you need.
    I think I could expose this in some of the coming updates, too.
     
  7. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    Thanks @tobiass this is exactly what I wanted but now Im getting these warnings
    "Had to lookup view that wasn't in dict: View (0)29 on Zombie(Clone)006 (scene)"

    So far Im just instantiating the gameobject using PoolManager and allocating an scene view id manually and assign it, these game objects gets disabled instead so I'm assuming something is going wrong with the viewIds when disable the object, so when try to instantiate a new object it picks an unused object (which had a previously set viewId) and assign a new viewId, so I how can avoid of getting these warnings?
     
  8. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    Hm. The we didn't have object pooling in mind when we built the PhotonView and manual viewID-allocation.
    The viewID can't be changed at the moment, so this probably breaks your case.
    Locally, the pool is a great tool to re-use stuff but for networked objects, you still need to carefully sync the other players.
    If you would re-set the viewID, PUN would need to update the others and the local caches.

    Maybe it's best when you remove the PhotonView from the pooled object.
    Do you de-allocate the IDs when a object goes back to the pool?
    This might turn out into a more complicated topic, so lets discuss this in our forum in a dedicated thread, please.
     
  9. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    We updated the PUN and PUN+ packages in the Asset Store. This update is about compatibility with Photon Chat, so there are just a few fixes aside from that.

    v1.27 (15. September 2014)
    Updated: Chat can now be used with PUN+ (after a Chat API update)! Updated assemblies and native plugins for PUN+.
    Added: ServerSettings for PUN+ will not allow you to use TCP. PUN+ uses reliable UDP. Added a note about this fact in the inspector for ServerSettings files.
    Added: When switching the protocol for self-hosted server in ServerSettings, the port is switched to fit the new protocol, unless it was a custom port already.
    Fixed: Issue with "Best Region" hosting option and wrong AppIds. In this case, we now disconnect and call OnFailedToConnectToPhoton(DisconnectCause.InvalidAuthentication) and disconnect. Also, no pinging is done in this error case.
    Changed: When calling Connect*(null), the PhotonNetwork.gameVersion is not changed. You could set it once in a project and leave it alone in Connect*().
    Added: PhotonNetwork.gameVersion caches the game version that gets set via any of the Connect-methods. This can be useful when a client needs to re-connect.
    Internal: The two internal cleanup methods LeftRoomCleanup() and LeftLobbyCleanup() are no longer called from various places but only on disconnect (which happens when you leave a room, too) and LeaveLobby(). This is cleaner internally.
    Added: OnConnectionFail callback with the case DisconnectCause.AuthenticationTicketExpired. This is a rare disconnect cause which usually means our server's timing is mixed up or your client uses a very (!) old authentication ticket. Handle this by connecting again (which will do a fresh authenticate).
    Changed: The callback OnPhotonInstantiate is now called via GameObject.SendMessage() like any other callback (as listed by enum PhotonNetworkingMessage). OnPhotonInstantiate can be a coroutine. If your implementation has 0 parameters it will be fine, too.
    Updated: To latest Photon Unity dll v4.0.0.3. This now tries to tell the server when the client timed out (used in counters to analyze issues) and it uses a newer native-socket-api. This is incompatible with older libs in Assets\Plugins\Android and Assets\Plugins\iOS! Update all when you use PUN+.
     
  10. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    @tobiass I'm not unallocating the id but I see what are you saying so I decided to move back the built in method but I just noticed I'm still getting that warning, I'm destroying the view and gameObject when the zombies die.

    Btw you can check out the game here: https://apps.facebook.com/infestedland/
     
  11. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    If I should take a look at how this happens, I would need the project, a simplified repro project or an extremely easy description how to setup a repro case myself.
    At the moment, I don't know enough to find the cause of the issue. You can mail me: developer@exitgames.com to send details.
     
  12. SlonCHL

    SlonCHL

    Joined:
    Jul 15, 2014
    Posts:
    8
    I have a question, if I use the best region setting to connect and 2 users connect to 2 different cloud servers, will they be able to connect to the same game?

    Edit: I tested my build with best region setting and another with a different server from the one chosen with best region setting, they don't seem to see each other. If so, can I ask if by using best region setting, will my CCU limit increase? Also, have the Asia region cloud server been repaired? I seem to connect to it faster and encountered no hassle.
     
    Last edited: Sep 22, 2014
  13. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    @SlonCHL: It's right, the regions are separate from each other. It makes sense to limit the region selection until there are enough players worldwide.
    Yes, we worked on the Asia servers. Good to read they work fine now.
     
    SlonCHL likes this.
  14. FundaySoftware

    FundaySoftware

    Joined:
    Sep 16, 2014
    Posts:
    22
    Is there an ETA on when the issue with viewID's clashing during async sceneload will be fixed? I would be happy to simply be able to control viewID's manually in the editor.
     
  15. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    There is no ETA yet but we plan to do exactly this type of improvements in the coming months, so we will try to find a proper fix for it.
    Can you describe your use case, so we can make that part of the design we do? You want to load scenes incremental or do you replace the ones you got?
     
  16. FundaySoftware

    FundaySoftware

    Joined:
    Sep 16, 2014
    Posts:
    22
    We are currently loading our scenes additively, and asynchronously. When the load is done, we clean up the old scene manually (there are a multitude of reasons for doing this). We have different photonviews in different scenes ( 1 in lobby scene, multiple in game scene). I had difficulties assigning ID's manually. In the lobby scene, it would just flip back to ID 1 (this is in the editor, not at runtime.), but for some reason, I'm now able to assign it without any hassle. This puzzles me. The basic use case is having multiple photonviews across different scenes, that should all have unique ID's on a project wide basis. I would imagine a "manual mode", where an editor tool could simply find all photonviews in all scenes and assign ID's that way.
     
  17. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    Normally, you should be able to assign IDs manually and save them. You just can't enter "0" or "". This will trigger fixing of the IDs in a scene.
    Right now, I went for the "easy to do" route: I added so called "PunSceneSettingsFile" and it lets you enter a list of scene names and a minimum ViewID per entry. When the ViewIDs are assigned or fixed, the scene ViewIDs will begin with the minimum value you define (if any).

    This is not extremely elegant. I know. I just don't know if I should spend more time this topic, if it's quite uncommon.
    I will have to evaluate other options.
     
  18. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    An update is now in the Asset Store:

    v1.28 (23. September 2014)
    Changed: Compile conditions for WII U should work now! The demos don't run out of the box on Wii U though. You need to adjust some screen settings to get the GUI and input right.
    Changed: Ping on native platforms does not disconnect PUN anymore.
    Updated: FindFriends documentation.
    Added: PunSceneSettings. This allows you to define the minimum value for ViewIDs per scene-file name. This helps to avoid clashes between ViewIDs when switching scenes or loading multiple incrementally. A PunSceneSettingsFile is created and only used in the Editor. Add names of scenes and their minimum ViewID value. Any scene that is not entered, begins at 0. You must edit at any PhotonView in each scene to correct the scene-views! Save the scenes.
    Updated: To library v4.0.0.5 which fixes a problem with CRC Checking and reduces the amount of logging it does. See details in the separate release history file.
     
  19. LoDx

    LoDx

    Joined:
    Feb 13, 2013
    Posts:
    67
    Hi @tobiass,
    I imported the v1.28 PUN+ into a new fresh project, and get error :-
    Assets/Photon Unity Networking/Plugins/PhotonNetwork/PingCloudRegions.cs(17,31): error CS0246: The type or namespace name `PhotonPing' could not be found. Are you missing a using directive or an assembly reference?

    By the way, possible to update the Photon Angry Bots Multiplayer Demo (https://www.assetstore.unity3d.com/en/#!/content/1917) with latest version of PUN ?

    Thanks
     
  20. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    @LoDx: Which platform are you on and which is selected for export?
    Yes, we can update the demo to the latest version, of course. It just wasn't high prio. Will try to get that done next week.
    Edit: And which version of Unity are you using?
     
    Last edited: Sep 25, 2014
  21. LoDx

    LoDx

    Joined:
    Feb 13, 2013
    Posts:
    67
    Hi @tobiass ,

    My platform : Window 8 ; unity3d project build/export : PC,Web,Standalone
    Unity version : 4.5.2

    Last week I was trying out with v1.27 on the same machine/build, didn't encounter such error. Saw the version update to v1.28 , and updated it...unfortunately I didn't keep copy of v1.27 .

    Thanks
     
  22. LoDx

    LoDx

    Joined:
    Feb 13, 2013
    Posts:
    67
    @tobiass,
    ok, I believe I know that cause of the error...it's the Photon Angry Bots Multiplayer Demo (https://www.assetstore.unity3d.com/en/#!/content/1917) , as the demo package is still v1.25 , it's not compatible with PUN v1.28.
    - I create new project, import v1.28 -> no error
    - then I import the Photon Angry Bots Multiplayer Demo , and the same error shows up.

    Thanks tobiass for your kind time. Hopefully the demo pack could be upgraded accordingly. It's a great starting point for new PUN users.
     
  23. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    Your error really sounded like an import issue but I read your post somehow wrong or so.
    Good you found it!
    You should be able to import PUN 1.28 in a new, empty project and then copy and paste the Editor folder and the Plugins folders (there are two) into the Angry Bots Demo in Finder or Windows Explorer. It's important that PUN's new files all overwrite existing ones.
    I will look into updating the other packages next week.
     
  24. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    I just updated PUN to v1.28.1, fixing an annoying bug with PhotonView viewIDs re-assignment.
    Please update when you use v1.28 already. Sorry for the hassle.
     
  25. Keith90

    Keith90

    Joined:
    Sep 27, 2013
    Posts:
    116
    Hello.

    I have never programmed an online multiplayer before and I was looking to start now. My game is a 2D arena fighter (using 3D physics), similar to Smash Bros/Towerfall in terms of movement. How difficult would it be for me to pick up Photon and learn, despite having no prior knowledge? I'd like to think that due to the simplicity of the game, it wouldn't require much.

    Thanks for any advice/information. I greatly appreciate it.

    - Keith

    Edit: So I managed to get a few things to work. However, I seem to have an issue with ReceiveNext();

    I'm using a plugin called Puppet2D and using a bool from one of the scripts. The bool is called flip, so I tried using that. However, I seen people create a new bool and reference whatever bool they are using. So I did canFlip = script.flip;

    In the OnPhotonSerializeView section, I put.

    canFlip = (bool)stream.ReceiveNext();

    However, I get "No overload for method `ReceiveNext' takes `1' arguments".

    Also, it seems animations don't work. I try using the animator, but nothing. Also, one of the players has their Z.rotation locked on their rigidbody, which is odd. This is a lot more complicated than I thought and maybe not worth it for my game.

    Can anyone please tell me the proper way to be able to use a bool from another script in Photon. I'd greatly appreciate it. :)
     
    Last edited: Sep 28, 2014
  26. thanhle

    thanhle

    Joined:
    May 2, 2013
    Posts:
    162
    why when play game use photon unity networking CPU work so high ? ,
    i checked in processes is ( 12 -15 )
    it will make lagg if use weak hardware !
     
  27. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    @Keith90: The error you get is about how you used ReceiveNext(). The code you posted should be fine while the error would point you to some slightly different line of code. Double-click the error log in the console and check the code.

    @thanhle: The process does not show PUN's CPU usage but that of the whole game. If it's higher than without multiplayer, it might be related to more action going on, more units/characters or whatever else you do in multiplayer. Usually, PUN will only take a few milliseconds to process messages in the few frames that it actually does something.
     
  28. thanhle

    thanhle

    Joined:
    May 2, 2013
    Posts:
    162
    i Have a question :
    a.png
     
  29. roberto-ardila

    roberto-ardila

    Unity Technologies

    Joined:
    Apr 8, 2013
    Posts:
    5
    Hello, we have a little problem with PUN, we have sucessfully making some tests in which we can move multiple players and send RPC calls, but when we add an OnPhotonSerializeView everything begins to work weird, for example the clients begin to "teletransport" between the origin and the current position without control, we try every combination of options and also different versions of PUN and Unity, we set the observe object correctly, we put some Debug.Log in the method but it seems that the method is never called so the problem persist, even the examples don't work when we add a new PhotonView and then an OnPhotonSerializeView method, the only thing we see that is different from out tests is that in the examples (Marco-Polo,etc) the PhotonView Component doesn't have the Serialization parameter, we don't know what the problem migth be, Thanks a lot
     
    Last edited: Oct 4, 2014
  30. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    @thanhle: You need to select one of the IPs your machine has before you start Photon Server.
    If you want to use a public IP you need to know it and all routers and firewalls must be setup to allow connections on the ports Photon uses.
    See:
    http://doc.exitgames.com/en/onpremise/current/reference/firewall-settings
    http://doc.exitgames.com/en/onpremise/current/getting-started/requirements

    @roberto.ardila: It is probably just a small mix up but without the actual project, it's not possible to say whats going on. Maybe RPCs are still fired and overlap with OnPhotonSerializeView?
    I would start from scratch to make sure you get the basics correct. When you have an understanding of those, you can implement what you are trying to do now.
    Work through this: http://doc.exitgames.com/en/pun/current/tutorials/tutorial-marco-polo
     
  31. Neoshiftr

    Neoshiftr

    Joined:
    Dec 5, 2012
    Posts:
    67
    Are there any tutorials on how to use Photon Cloud with playfab?
     
  32. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    @ITGeist: Not yet. But both products should fit together quite nicely and the independent tutorials should do for a starter.
     
  33. Ryuuguu

    Ryuuguu

    Joined:
    Apr 14, 2007
    Posts:
    391
    I just downloaded 1.28.2 in to an empty scene and entered my App id in to the wizard.
    I then went to DemoBoxes scene and nothing is linked. I mean all materials in object are none, all fonts list as missing and all scripts list as missing mono script. I tried this in Unity 4.5.4f1 and 4.3.7p3 .
    Is this 1.28.2 problem, or is there some step I am missing?
     
  34. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Yeah same here, I posted on their official forums as well.
     
  35. jtadeo1

    jtadeo1

    Joined:
    Oct 18, 2006
    Posts:
    78
    It's broken. I let them know about it a few days ago. Here's what I'm getting:


    At first I thought I had messed something up with my settings. I'm looking for a previous version. I normally save out a backup but not this time.
     
  36. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    I will take a look at 1.28.2 and release a fix asap.
    This should have been a simple fix but most likely the meta files are broken.
    Sorry for the inconvenience and thanks for letting me know.
     
  37. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    I just uploaded 1.28.3 and verified it. Please re-download.
    Sorry again for the trouble.
     
  38. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Tobiass did I notice there are new demos in this version??? The one I had before didn't have anything but the basics. Now I'm actually seeing how to create rooms and lobbys and stuff :)..

    Definitely AWESOME!!! lol.
     
  39. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    Some demos were in the package all the time but there is a new-ish one which features (item) Pickup and Teams. It also has an implementation for Player Scores.
    We will write some stuff about each but at the moment, the demos are about the code you get. A showcase, not a tutorial so much.

    Glad you like it :)
     
  40. TDH_DrThirteen

    TDH_DrThirteen

    Joined:
    Jul 3, 2014
    Posts:
    42
    I tried to upgrade my recent project to Unity 5 but it stuck during the import of Photon.
    Does Photon work with Unity 5?
     
  41. marchinram

    marchinram

    Joined:
    Jan 28, 2014
    Posts:
    5
    I'm using the standalone service and extending the LoadBalancingClient class, after joining the lobby how can I lookup the games list. I see OnEvent being called with a EventCode.GameList event but don't see any data attached to it.
     
  42. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    @TDH_DrThirteen: I didn't check it out in a while but it should work, yes. When it gets stuck during import: Can you try to not import the Demo folder?

    @marchinram: LoadBalancingClient.OnEvent should read the room list and put it into LoadBalancingClient.RoomInfoList.
    You need to get one client into a room which is visible. Else, the list will be empty.
    If you can't resolve your issue, let's discuss this in our "DotNet" forum please. This thread should be about Photon Unity Networking (might be confusing to even refer to LoadBalancingClient as it's not in PUN).
     
  43. itachi4365

    itachi4365

    Joined:
    Sep 24, 2012
    Posts:
    40
    I am trying to login on photon using Facebook, but I am getting Custom Authentication Failed error.
    After debugging I got this error code "The request is invalid because the app is configured as a desktop app". I am not able to understand this, what does it mean?
    Is the configuration wrong on the facebook side or the photon side?
     
  44. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
  45. itachi4365

    itachi4365

    Joined:
    Sep 24, 2012
    Posts:
    40
    Thanks for the quick reply, but I have done that too, but its still not working.
     
  46. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    Are you sure you use the correct FB App IDs and everything?
    In worst case, please also get in contact with the FB support. The error comes from their side, afaik, so maybe the config is broken or something.
     
  47. itachi4365

    itachi4365

    Joined:
    Sep 24, 2012
    Posts:
    40
    They have close it but its still not working, Need help, please!
     
  48. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    I can't follow you. Who closed what? How is closing related to this?
    You got no help / explanation from their side?
     
  49. itachi4365

    itachi4365

    Joined:
    Sep 24, 2012
    Posts:
    40
    As per your suggestion that I should contact Facebook to see if the problem is at their side, I did that and they said they have closed it and didn't divulge any further details.
    Also I found that this problem is occuring on Unity 4.5 and is working perfectly fine on Unity 4.2, and I think it si because I have been using PUN+ version 1.24.
     
  50. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    @itachi4365: Did you update PUN and does it work now? It sounds like that.