Search Unity

  1. Dismiss Notice
  2. We have added sub-forums for the experimental MLAPI and Unity Transport Package. Please use the new forums to discuss related topics.
    Dismiss Notice
  3. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  4. Dismiss Notice

Photon Unity Networking

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

  1. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
  2. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    387
    Hello, I just updated to unity 5.1, and it gives compiler erros from uNet, below is the error;

    UNetWeaver error: Exception :System.NullReferenceException: Object reference not set to an instance of an object
    at Unity.UNetWeaver.Weaver.CheckSyncListStruct (Mono.Cecil.TypeDefinition td) [0x0003e] in C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetWeaver.cs:1420
    at Unity.UNetWeaver.Weaver.Weave (System.String assName, IEnumerable`1 dependencies, System.String unityEngineDLLPath, System.String unityUNetDLLPath, System.String outputDir) [0x0006d] in C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetWeaver.cs:1461
    UnityEngine.Debug:LogError(Object)
    Unity.UNetWeaver.Log:Error(String) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/Program.cs:19)
    Unity.UNetWeaver.Weaver:WeaveAssemblies(IEnumerable`1, IEnumerable`1, String, String, String) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/UNetWeaver.cs:1538)
    Unity.UNetWeaver.Program:process(String, String, String, String[], String[], Action`1, Action`1) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/Program.cs:33)
    UnityEditor.Scripting.Serialization.Weaver:WeaveUnetFromEditor(String, String, String, String, Boolean)


    Failure generating network code.
    UnityEditor.Scripting.Serialization.Weaver:WeaveUnetFromEditor(String, String, String, String, Boolean)

    I tested removing photon and my codes related to photon, it compiles. Do you have an idea why this happens? Thanks.
     
  3. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
    @Meceka: Ow. That's ugly. But it's a bug on Unity's side. It should not interact with PUN at all, because it's not related at all, code-wise.
    Please report a bug to Unity.
    I currently don't know if UNet is a plugin which you could skip from the project or if it's built-in already.
     
  4. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    387
    There was also these errors that happen on PhotonAnimatorViewEditor.cs, but I deleted that script before posting my earlier reply. (I am not using animations). I am not sure if it's related to deleting that script, so here are those errors.

    Assets/Photon Unity Networking/Editor/PhotonNetwork/Views/PhotonAnimatorViewEditor.cs(60,55): error CS1061: Type `PhotonAnimatorViewEditor' does not contain a definition for `m_Controller' and no extension method `m_Controller' of type `PhotonAnimatorViewEditor' could be found (are you missing a using directive or an assembly reference?)

    Assets/Photon Unity Networking/Editor/PhotonNetwork/Views/PhotonAnimatorViewEditor.cs(60,22): error CS1061: Type `PhotonAnimatorViewEditor' does not contain a definition for `m_Controller' and no extension method `m_Controller' of type `PhotonAnimatorViewEditor' could be found (are you missing a using directive or an assembly reference?)

    Also, on each [RPC], i am having these warnings;

    Assets/Photon Unity Networking/Editor/PhotonNetwork/PhotonEditor.cs(922,57): warning CS0618: `UnityEngine.RPC' is obsolete: `NetworkView RPC functions are deprecated. Refer to the new Multiplayer Networking system.'

    If you can find a way to disable uNet please share.
     
  5. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
    A minor update for PUN:

    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.
     
  6. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
    @Meceka: I can hardly support you on that level. You delete scripts and are unable to relate the error message to that. Yes, that error is related...
    At the moment, I can't help with the RPC "obselete" warnings at compile time. You can safely ignore it, though. A solution would require you to replace all [RPC] attributes. I don't want to force this on everyone at the moment.
    Maybe in another, more profound update.
     
  7. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    387
    For everyone having "UNetWeaver error: Exception :System.NullReferenceException: Object reference not set to an instance of an object" error;

    Delete script: PhotonConverter.cs
    Comment out line 595 on PhotonEditor.cs which is: "PhotonConverter.RunConversion();"

    I spent about 8 hours deleting scripts one by one to find the cause. You could at least lead me to that converter script. It's clearly interacting with unity networking.
     
    twobob likes this.
  8. K-z3

    K-z3

    Joined:
    Aug 19, 2012
    Posts:
    1,673
    Best Region Setting does not seem to work for WebGL! I get the following console error when using Best Region:
    Code (CSharp):
    1. Authentication failed: 'Cloud Public / Region none is not available.' Code: 32756
    2. UnityEngine.Debug:LogError(Object)
    3. NetworkingPeer:OnOperationResponse(OperationResponse) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1150)
    4. ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[])
    5. ExitGames.Client.Photon.TPeer:DispatchIncomingCommands()
    6. ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
    7. PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:83)
    Although if I switch Platform to Webplayer, it works perfectly fine. Please assist with resolving this issue, I really need this feature for my game. Thanks!
     
  9. BonbonChan

    BonbonChan

    Joined:
    Feb 16, 2014
    Posts:
    6
    Hi,

    I have a hard time to make PUN works under Windows Store (sdk 8.1). My game works fine under native x86 and Android. I'm using Unity 5.0.2f and Photon PUN 1.54.
    So far, what I have done :
    • I have fixed the Photon3Unity3D.dll problem.
    • When I export, I got a problem with WebSocket.cs. I fixed it with :
    #if UNITY_WSA && !UNITY_EDITOR
    using Windows.Networking.Sockets;
    #else
    using System.Net.Sockets;
    #endif

    So now, it compile fine under Visual Basic and the game runs.
    I have internet acces with WWW class but PUN doesn't work online (it works offline).

    In player settings, I have put (i'm not sure what I need) :
    • InternetClient
    • InternetClientServer
    • PrivateNetworkClientServer
    Do I miss something ?
    Is there a simple way to test the PUN connectivity (like Application.internetReachability) ?
     
    Last edited: Jun 14, 2015
  10. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
    Thanks for posting this and I am terribly sorry to read you spent so much time on that. We're not aware of that issue. I assume it's Unity 5.1?
    I will remove the converter in one of the next updates. It's outdated now, anyways.
     
  11. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
     
  12. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
    I will have to look into this.
    The easiest check if you can go online with PUN is to connect. There is no other test that's valid.
    Do you get anything logged on device?
    Can you please post any follow up in it's own thread in our forum? It's easier to follow than in this wild mix of topics :)
    http://forum.exitgames.com/
     
  13. K-z3

    K-z3

    Joined:
    Aug 19, 2012
    Posts:
    1,673
    @tobiass

    Ah man... I'm really sad to learn this... Do you guys have an example code, or projects with how to setup the Select Region Menu Options? I was hoping to avoid having to set this up, as I want players to have the best experience. Players jumping into other Regions will increase lag, and ruin the game for others with my kind of game.

    I know I could probably setup some kind of Javascript that detects players ip/region then redirect player to a different build of the game based on region. But now this requires me to maintain 5 separate builds of the game (not something I want to do).

    Hopefully you guys can find a way to get this to work with WebGL.
     
  14. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
    @Kuroato: This is taking the thread a bit off topic but: Isn't there some way to push JS values into the client maybe?
    Then you only have to detect the region externally and inject this. I never looked at the .jslib we use for websockets. Maybe that's a way to make it work...?
     
  15. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
    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, starting with this PUN version.
     
  16. K-z3

    K-z3

    Joined:
    Aug 19, 2012
    Posts:
    1,673
    Possibly, I'll have to look into it I guess. So is this something that you guys don't plan on supporting? Best Region feature seems to work on all other platforms, so i'm just curios why I would be left to figure it out on my own? Shouldn't this be a feature you guys want to add to WebGL? As of right now I feel like i'm just being told tough cookies, go figure it out.

    I'm asking for a solution to a feature that I believe should also be supported on WebGL as it is with all other platforms. I know you mention it may not be an easy thing to do, but i'm certain your team can figure out the best way to support Best Regions on WebGL.

    Being among the only few if not the only person showcasing successful progress with WebGL and Photon in a Multiplayer Third Person Shooter. I would hope to get a little better support than a shoulder shrug reply.

    Best Regions is very very import for WebGL and Photon as for my case example i'm using Photon Cloud Backend. With WebGL performing at 1/3 of that of Unity Webplayer, we have the challenge of dealing with lower FPS (performance) in 3D WebGL Games. Which if a client is lagging locally due to system performance issues, it will greatly effect latency, and produce delays for the game over the network. One way we can address this is by forcing all clients to only connect to their respective regions for overall better gameplay experience on all ends. Even if one client lags due to WebGL or system performance issues, at least the side effects will be greatly reduced if players are connected to other players in their Region and not elsewhere.

    Beyond the WebGL performance issue which may not be a strong enough case for you as WebGL performance is not really your problem, still Best Regions is a huge benefit in my case as I have found major lag, delays, and sync issues in my WebGL game that were caused due to latency between clients joining remote regions.

    A Region Selection Screen is not the solution because players with a higher-ping can easily ruin the game for others if they even have the option to join a remote region. The best solution is Best Regions, but as of this moment I'm being told i'm on my own... is this really how this is going to end? or will you guys actually look into providing a solution to support Best Region feature in WebGL?

    You did say you can look into it, but there is a huge difference between saying you actually will look into vs "you can" which sounds more like a big maybe or no based on your follow up response pushing for me to figure out something on my own which your team should be working on to address.
     
    Last edited: Jun 17, 2015
  17. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
    @Kuroato: It seems you take this a bit personal. Your post sounds like you feel ignored or worse. Calm down.
    I mailed with you quite a bit over the last few weeks. In the early access group for WebGL, you more or less refused to give feedback and preferred to wait for the release.
    While you might have the only thirdperson shooter webgl game right now, this is not the only game we support and webgl is neither the only platform, nor the biggest one.
    Bear with us, while it's growing. Websockets are very different from what we do on other platforms. It's all new and we can't say when we can finish stuff.

    My "we look into it" means "we want to fix it but i can't say when".
    I tried to support you with alternative options.
    Sorry if that's not enough.
     
  18. K-z3

    K-z3

    Joined:
    Aug 19, 2012
    Posts:
    1,673
    OK, I am calm... sorry if I sound whiny or something but I just thought supporting WebGL was one of your top priorities especially being that you have the only well known working Unity WebGL Networking Solution thus far. Your replies come off more like your pushing for me to figure it out over you actually taking ownership of a problem with your product. Otherwise you would have said "OK, we will look into it, but in the meantime try this" that's a very different kind of response and level of support from what you expressed.

    Anyway, I'm working on a Region Select Option in the meantime. Hopefully it will help reduce laggy gameplay experience compared to the current setup (if players actually pick their closest region that is). I honestly don't have the time right now to figure out how to develop a custom external JS IP / Region / Ping Solution that can feed the results back into the game, sounds very messy anyway. Best Region feature should work directly from the game somehow, not outside of it.
     
  19. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
    I am with you and we will look into this. However, I have a hard time promising anything right now with Unite Amsterdam next week and several other topics, too.
    I misunderstood you, too: post 813 sounded like you know JS well enough to come up with a temporary solution quite easily. My suggestion to look into jslib was based on that.

    Ok. Thanks for taking the time to reply and clear this. I can't promise a timing really but we will fix best region in WebGL.
     
  20. K-z3

    K-z3

    Joined:
    Aug 19, 2012
    Posts:
    1,673
    OK, have fun at Unite! ;)

    I'll use Region Select Option for now and hope players pick their closet region. And yep, I wouldn't know where to begin with coding JS. :confused:
     
  21. K-z3

    K-z3

    Joined:
    Aug 19, 2012
    Posts:
    1,673
    OK, so I am now getting the following Error when trying to create a Region Select Menu Option by using the following code (below). I have a Region Select Option (Button) that is set to connect to app-us.exitgamescloud.com "app-eu, app-asia...", but when clicked it does not work at all!

    Code (CSharp):
    1. PhotonNetwork.ConnectToMaster("app-us.exitgamescloud.com", 19090, "123fake-app-id456-1f34-1a3f56b8e23", "1.0");
    I get the following error:

    Code (CSharp):
    1. ArgumentException: Unsupported protocol: app-us.exitgamescloud.com
    2. WebSocket..ctor (System.Uri url) (at Assets/Plugins/WebSocket/WebSocket.cs:22)
    3. ExitGames.Client.Photon.SocketWebTcp.Connect () (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/SocketWebTcp.cs:83)
    4. ExitGames.Client.Photon.TPeer.Connect (System.String serverAddress, System.String appID)
    5. ExitGames.Client.Photon.PhotonPeer.Connect (System.String serverAddress, System.String applicationName)
    6. NetworkingPeer.Connect (System.String serverAddress, ServerConnection type) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:326)
    7. PhotonNetwork.ConnectToMaster (System.String masterServerAddress, Int32 port, System.String appID, System.String gameVersion) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:1293)
    8. UIManagerScript.ConnectToRegion1 () (at Assets/Scripts/UIManagerScript.cs:63)
    9. UnityEngine.Events.InvokableCall.Invoke (System.Object[] args) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:137)
    10. UnityEngine.Events.InvokableCallList.Invoke (System.Object[] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:601)
    11. UnityEngine.Events.UnityEventBase.Invoke (System.Object[] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:743)
    12. UnityEngine.Events.UnityEvent.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent_0.cs:53)
    13. UnityEngine.UI.Button.Press () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:35)
    14. UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:44)
    15. UnityEngine.EventSystems.ExecuteEvents.Execute (IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:52)
    16. UnityEngine.EventSystems.ExecuteEvents.Execute[IPointerClickHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:269)
    17. UnityEngine.EventSystems.EventSystem:Update()
    It seems I only get this error in WebGL, but once I switch to Web Player Platform (and update port to 5055) in the Editor it works fine. I really hope you guys can fix this or offer me a solution really soon as this was my alternative option from not having the ability to use Best Region feature in WebGL, but now this doesn't work either... arg! :mad:
     
    Last edited: Jun 19, 2015
  22. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
    @Kuroato: You can't connect to the Master Server with that host name, because Secure WebSockets use a different notation and require a certificate, etc.. It's way more complicated than what we do otherwise.
    I'll send you a pm with suitable code and add it to PUN in the next update (in 3..4 weeks).
     
    K-z3 likes this.
  23. Bioman75

    Bioman75

    Joined:
    Oct 31, 2014
    Posts:
    72
    Hello I am getting these errors in my project since the v1.56 update.


    PhotonView with ID 5 has no method "AddNewKillFeed" marked with the [PunRPC](C#) or @PunRPC(JS) property! Args: String, String, String, String, Int32, Int32
    UnityEngine.Debug:LogError(Object)
    NetworkingPeer:ExecuteRpc(Hashtable, PhotonPlayer) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2288)
    NetworkingPeer:RPC(PhotonView, String, PhotonTargets, Boolean, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3053)
    PhotonNetwork:RPC(PhotonView, String, PhotonTargets, Boolean, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:2632)
    PhotonView:RpcSecure(String, PhotonTargets, Boolean, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:608)
    PhotonView:RPC(String, PhotonTargets, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:582)
    bl_KillFeed:OnJoined() (at Assets/MFPS/Scripts/UI/bl_KillFeed.cs:157)
    bl_KillFeed:Awake() (at Assets/MFPS/Scripts/UI/bl_KillFeed.cs:41)

    PhotonView with ID 1001 has no method "SyncDamage" marked with the [PunRPC](C#) or @PunRPC(JS) property! Args: Single, String, String, Vector3, Boolean, Int32, PhotonPlayer
    UnityEngine.Debug:LogError(Object)
    NetworkingPeer:ExecuteRpc(Hashtable, PhotonPlayer) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2288)
    NetworkingPeer:RPC(PhotonView, String, PhotonTargets, Boolean, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3066)
    PhotonNetwork:RPC(PhotonView, String, PhotonTargets, Boolean, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:2632)
    PhotonView:RpcSecure(String, PhotonTargets, Boolean, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:608)
    PhotonView:RPC(String, PhotonTargets, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:582)
    bl_PlayerDamageManager:GetDamage(bl_OnDamageInfo) (at Assets/MFPS/Scripts/Network/bl_PlayerDamageManager.cs:207)
    bl_PlayerDamageManager:Suicide() (at Assets/MFPS/Scripts/Network/bl_PlayerDamageManager.cs:376)
    bl_RoomMenu:MainMenu() (at Assets/MFPS/Scripts/GamePlay/bl_RoomMenu.cs:354)
    bl_RoomMenu:OnGUI() (at Assets/MFPS/Scripts/GamePlay/bl_RoomMenu.cs:247)

    PhotonView with ID 1001 has no method "SyncSteps" marked with the [PunRPC](C#) or @PunRPC(JS) property! Args: String, String
    UnityEngine.Debug:LogError(Object)
    NetworkingPeer:ExecuteRpc(Hashtable, PhotonPlayer) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2288)
    NetworkingPeer:RPC(PhotonView, String, PhotonTargets, Boolean, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3053)
    PhotonNetwork:RPC(PhotonView, String, PhotonTargets, Boolean, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:2632)
    PhotonView:RpcSecure(String, PhotonTargets, Boolean, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:608)
    PhotonView:RPC(String, PhotonTargets, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:582)
    bl_FootSteps:Update() (at Assets/MFPS/Scripts/Network/bl_FootSteps.cs:46)
     
  24. Bioman75

    Bioman75

    Joined:
    Oct 31, 2014
    Posts:
    72
    @Bioman75

    I think it might have to do with RPC not being supported any more but I don't know how to fix this.
     
  25. w34edrtfg

    w34edrtfg

    Joined:
    Nov 23, 2014
    Posts:
    55
    I've upgraded my Windows project to Unity 5.1 and i've also updated Photon. This is what i get:
    Code (CSharp):
    1. Assets/Photon Unity Networking/Plugins/PhotonNetwork/LoadbalancingPeer.cs(29,103): error CS0117: `ExitGames.Client.Photon.ConnectionProtocol' does not contain a definition for `WebSocketSecure'
    It was also throwing errors in "Assets/Plugins/ChatApi", but i deleted the entire folder since i don't use that feature.
     
  26. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
    @w34edrtfg: Chat does not support WebGL yet. So at the moment, removing this folder is probably best.
    Sorry for the hassle.

    @Bioman75: I hoped the error message points you in the right direction. We were forced to switch to another attribute to mark RPC methods: PunRPC. In Unity 5.1, the RPC attribute became obsolete and caused too many compile warnings.
    Update your code by replacing [RPC] to [PunRPC] for C# or @RPC to @PunRPC for Unityscript.
     
  27. SmartCarrion

    SmartCarrion

    Joined:
    Jul 27, 2013
    Posts:
    22
    Hi, thanks for making this! The new switch to 'PunRPC' has broken a PhotonServerSettings function. When I click the "Clear RPCs" button on the PhotonServerSettings file, it deletes all the RPCs, but does not find the functions with the new tag [PunRPC]. I can work around it by doing find->replace to [RPC], refreshing/clearing the RPCs, then find->replace to [PunRPC].
     
  28. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
    Ouch. What a bummer! I missed PhotonEditor.UpdateRpcList(). It is still looking for UnityEngine.RPC.

    Find
    if (method.IsDefined(typeof (UnityEngine.RPC), false))
    and replace it with
    if (method.IsDefined(typeof (PunRPC), false))

    I will update PUN asap. An update should be in the Asset Store later today.
     
  29. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
    The fixed version is up. We also added an automatic search and replace dialog for the new RPCs in case we find the old ones.
    WebGL has still some limitations, so please read the notes at the end of the changelog.

    v1.57 (22. June 2015)
    Fixed: An issue with the RPC list update, which was still looking for the old RPC attribute. So when you switched over to PunRPC, the list was empty.
    Added: Automatic check if the obsolete RPC attribute is in source, to offer an automatic conversion to the new PunRPC attribute. Conversion uses search and replace for [RPC] to [PunRPC] and @RPC to @PunRPC.
    Added: PhotonNetwork.ConnectToRegion(), which enables you to connect to a specific region easily. This can be useful when you do your own region selection.
    Note: Best Region selection won't work in WebGL exports currently. A fix needs updates on the server side and is in work.
    Note: Chat API won't work in WebGL exports at the moment. Delete it from a project which targets WebGL.
    Note: PUN+ does not support WebGL at the moment. It requires an update of the lower level APIs which we work on. Unity 5 can export PUN Free to all platforms, so use this as workaround.
     
  30. w34edrtfg

    w34edrtfg

    Joined:
    Nov 23, 2014
    Posts:
    55
    Everything is working fine for me now, thanks for fastfixing.

    Edit: Looks like you left a debug trace in LoadbalancingPeer.cs:
    Code (CSharp):
    1. if (!string.IsNullOrEmpty(authValues.UserId))
    2. {
    3.                     UnityEngine.Debug.LogWarning("UserId sent: " + authValues.UserId);
    4.                     opParameters[ParameterCode.UserId] = authValues.UserId;
    5. }
    Also displays me a:
    I used your autoconversion. I've checked if there was any missing RPC in Assets/ and got 0 results, but stills throwing this warning.
     
    Last edited: Jun 22, 2015
  31. sumpfkraut

    sumpfkraut

    Joined:
    Jan 18, 2013
    Posts:
    195
    I used your autoconversion too. All RPC's are changed. But i still get the RPC attribute outdated popup window evrytime i saved a script, exit playmode, or load a project.
     
  32. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
    Good catch about the UserId. It's not a big deal hopefully. Will fix it in the next update.
    The remaining use of UnityEngine.RPC is in the converter itself. It's used to find the attribute in the first place. I forgot to add a pragma to suppress that last compile warning. At least there are fewer warnings now.
    More after Unite EU
     
  33. alecie

    alecie

    Joined:
    Sep 2, 2013
    Posts:
    73
    It only allows for 20 concurrent users? This is next to nothing. Even the paid plan for 100 users seems very little.

    Is it possibile to just use the cloud as masterserver for unlimited connections and letting players run their servers?
     
  34. w34edrtfg

    w34edrtfg

    Joined:
    Nov 23, 2014
    Posts:
    55
    Pss, their business is multiplayer services, they are not an NGO
     
  35. TheMave

    TheMave

    Joined:
    Jan 9, 2015
    Posts:
    7
    With an older version of Pun+ (v1.50), used with Unity 4.5.5 and Unity 4.6.6.f2, Pun+ worked great on Android device as well.

    After downloading the latest version of Pun+ (v.1.57) [the same standard package including demos], it works on pc+webplayer, but not on Android. I've tried this on Unity 4.6.6.f2 and Unity 5.1.1.f1 (32bit) and Unity 5.1.1.f1 (64bit). In all of these cases, the default demo on the android device returns "Connection failed". In the player settings for android build, I've just filled in an app name and bundle id, and left the other fields as default.

    As I haven't seen posts of others about this, I guess I must be doing something wrong.
    Could anyone give me a clue?
     
  36. forcepusher

    forcepusher

    Joined:
    Jun 25, 2012
    Posts:
    224
    Let's say I've got 6 players who send 5-10 messages per second. That's already up to 360 messages per second, so all I have left is 140 messages for NPCs.
    Every NPC involved in combat should send about the same amount of messages per second, and every player must receive their state updates full time (otherwise if master client leaves, then states of hidden NPCs will be completely lost).
    If every player must receive up to 10 messages per second from a single NPC, then we can do only 140 / (10*6) NPCs involved in combat, which is only 2. But I wanted like 20-50.

    (TL;DR) What if I connect states of all the NPCs together and send them in a single giant state update message ? Would that work ?

    From what I've read in some photon docs, maximum message size is 512000 bytes, which is almost 0.5 megabytes. I tried sending huge packets on state updates, and successfully sent 32 kilobyte strings every 0.25 seconds (you can fit about 200 NPC states in 32 kilobytes).
    I'm not going for lockstep synch design because it would be too complicated for my game type.
     
  37. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
    I didn't try those Unity versions explicitly but several others. Most work but some have issues.
    It would be interesting to see if anything got logged to console? Any hint what's going wrong?
     
  38. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
    You can't use our Master Server service for self-hosted instanced but you are invited to extend Photon.

    100 concurrent users are not much but they also don't equal 100 sales of your game. Play time per day is not a lot. You can expect 10x that many daily active users and again 100x monthly active. For a fully managed service running for your one time payment, that's no robbery. Or is it?
     
  39. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
    @shame: As your NPCs basically behave like players, you effectively want to make a 60 player game. The simple logic we run in the shared Photon Cloud does not support that case. It's built for smaller user counts.
    You can re-think your ideas maybe. Does every NPC need to send updates all the time? What if no one is close by anyways? Can you maybe send the target position of a NPC (where it's going) instead of positions and animations? So you only have to send a new target every few seconds and every client does a local simulation? Only the Master Client makes decisions?

    I can not guarantee if it works the way you want to aggregate messages. Try it out. Give us some feedback and tell others about your clever solutions and they will respond. You might spawn a good conversation if you put some work into it.
     
  40. forcepusher

    forcepusher

    Joined:
    Jun 25, 2012
    Posts:
    224
    Thanks for quick reply and useful ideas. I managed to get message-per-second amount down to 4-6 (yay for extrapolation). NPCs send that much updates only when they are involved in combat, means only if some player is near.
    I will try to aggregate messages and post results here.
     
    Last edited: Jun 27, 2015
  41. Mr.Stein

    Mr.Stein

    Joined:
    Dec 4, 2013
    Posts:
    169
    Hi @tobias,
    im trying Photon on Android but is not working with Pun 1.5.7
    I have check the folder "Plugin -> Android" and i think there is no more the library files of Photon in this new build V1.5.7.. also is no more for IOS, maybe that is the problem?
     
  42. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
    @Mr.Stein: Huh, good find! I would never have expected that but the files are actually missing.
    It's surprising because the packaging before submission is automated on our side and didn't fail in 2 years.
    I will submit a fix asap and double check it's complete.
     
    Mr.Stein likes this.
  43. Mr.Stein

    Mr.Stein

    Joined:
    Dec 4, 2013
    Posts:
    169
    no problem @tobias, We're here to help :)
     
  44. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
    We just released a minor update with some fixes and changes. Better support for Unity 5.1 and fixed Android exports.

    v1.58 (30. June 2015)
    Fixed: Compile warning about last remaining reference to RPC attribute (in Unity 5.1) by suppressing the warning. This reference is only in the Editor scripts and works unless RPC gets removed.
    Removed: Native socket libs from Unity 5 PUN+ package. The native libraries are no longer useful and keep us from supporting more platforms that are covered by Unity. Using the Socket class in C# is no longer a Unity-license problem. Download from the Asset Store with Unity 5.x to get this package. In Unity 4.x, you still get the Android and iOS (32bit and 64bit) libraries.
     
  45. alecie

    alecie

    Joined:
    Sep 2, 2013
    Posts:
    73
    Can I use Photons masterserver only and let users host their own servers on their pcs? I don't want to be limited to n CCU.
     
  46. xenonmiii

    xenonmiii

    Joined:
    Aug 2, 2010
    Posts:
    147
    @tobiass I'm seeing some strange behaviour. I'm using facebook authentication and I have player A and player B both connected. Player A can see B. B disconnects (turns off device). A sees that B is now offline. B reconnects (turns back on device). A still sees B offline, but B can see A :S.

    Thoughts?
     
  47. Paradoks

    Paradoks

    Joined:
    Oct 13, 2009
    Posts:
    430
    Hi Tobias,

    I just downloaded the latest version of Pun+ and unity.
    I am launching a WebGL version on my mac running the latest Safari.

    The game seems to connect to the first screen, but when i launch the actual game, safari gives me that:

    Code (CSharp):
    1. An error occured running the Unity content on this page. See your browser's JavaScript console for more info. The error was:
    2. abort(-1) at jsStackTrace@http://localhost:50085/Development/WebGL_Build.js:1197:22
    3. stackTrace@http://localhost:50085/Development/WebGL_Build.js:1214:34
    4. abort@http://localhost:50085/Development/WebGL_Build.js:4451859:54
    5. _pthread_create@http://localhost:50085/Development/WebGL_Build.js:9375:64
    6. __ZN6il2cpp2os10ThreadImpl3RunEPFvPvES2_ [il2cpp::os::ThreadImpl::Run(undefined?F?*, void, void*)]@http://localhost:50085/Development/WebGL_Build.js:66401:24
    7. __ZN6il2cpp2os6Thread3RunEPFvPvES2_ [il2cpp::os::Thread::Run(undefined?F?*, void, void*)]@http://localhost:50085/Development/WebGL_Build.js:61930:48
    8. __ZN6il2cpp6icalls8mscorlib6System9Threading6Thread15Thread_internalEP12Il2CppThreadP14Il2CppDelegate [il2cpp::icalls::mscorlib::System::Threading::Thread::Thread_internal(Il2CppDelegate?**)]@http://localhost:50085/Development/WebGL_Build.js:54600:44
    9. _Thread_Thread_internal_m21723@http://localhost:50085/Development/WebGL_Build.js:4059687:37
    10. _Thread_Start_m6794@http://localhost:50085/Development/WebGL_Build.js:4060300:39
    11. _Thread_Start_m6333@http://localhost:50085/Development/WebGL_Build.js:4060464:21
    12. _AstarPath_Awake_m1194@http://localhost:50085/Development/WebGL_Build.js:2810063:22
    13. __Z24RuntimeInvoker_Void_t213PK10MethodInfoPvPS2_ [RuntimeInvoker_Void_t213?2(void**, undefined?S?*)]@http://localhost:50085/Development/WebGL_Build.js:4114536:32
    14. __ZN6il2cpp2vm7Runtime6InvokeEPK10MethodInfoPvPS5_PP12Il2CppObject [il2cpp::vm::Runtime::Invoke?5(void**, undefined?S?*)]@http://localhost:50085/Development/WebGL_Build.js:82619:38
    15. _il2cpp_runtime_invoke@http://localhost:50085/Development/WebGL_Build.js:34251:74
    16. __Z20il2cpp_invoke_method21ScriptingMethodIl2CppP15ScriptingObjectP18ScriptingArgumentsPP18ScriptingExceptionb [il2cpp_invoke_method?2()]@http://localhost:50085/Development/WebGL_Build.js:1299020:31
    17. __ZN19ScriptingInvocation6InvokeEPP18ScriptingExceptionb [ScriptingInvocation::Invoke(bool**)]@http://localhost:50085/Development/WebGL_Build.js:1642121:119
    18. __ZN19ScriptingInvocation6InvokeEPP18ScriptingException [ScriptingInvocation::Invoke(ScriptingException?**)]@http://localhost:50085/Development/WebGL_Build.js:1642070:64
    19. __ZN25ScriptingInvocationNoArgs13InvokeCheckedEv [ScriptingInvocationNoArgs::InvokeChecked()]@http://localhost:50085/Development/WebGL_Build.js:1642367:37
    20. __ZN13MonoBehaviour12AddToManagerEv [MonoBehaviour::AddToManager()]@http://localhost:50085/Development/WebGL_Build.js:1634555:53
    21. __ZN9Behaviour13AwakeFromLoadE17AwakeFromLoadMode [Behaviour::AwakeFromLoad?1()]@http://localhost:50085/Development/WebGL_Build.js:1258561:34
    22. __ZN13MonoBehaviour13AwakeFromLoadE17AwakeFromLoadMode [MonoBehaviour::AwakeFromLoad?1()]@http://localhost:50085/Development/WebGL_Build.js:1633959:55
    23. __ZN18AwakeFromLoadQueue28InvokePersistentManagerAwakeEPNS_4ItemEj17AwakeFromLoadMode [AwakeFromLoadQueue::InvokePersistentManagerAwake?1(AwakeFromLoadQueue::Item*, unsigned int)]@http://localhost:50085/Development/WebGL_Build.js:1685789:36
    24. __ZN18AwakeFromLoadQueue30PersistentManagerAwakeFromLoadEv [AwakeFromLoadQueue::PersistentManagerAwakeFromLoad()]@http://localhost:50085/Development/WebGL_Build.js:1685616:88
    25. __Z31CompletePreloadManagerLoadSceneRKNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEER18AwakeFromLoadQueue [CompletePreloadManagerLoadScene?S(undefined?N?&)]@http://localhost:50085/Development/WebGL_Build.js:1556398:60
    26. __ZN12SceneLoading9LoadSceneEiRKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEER18AwakeFromLoadQueue [SceneLoading::LoadScene?S(int, undefined?N?&)]@http://localhost:50085/Development/WebGL_Build.js:1521955:123
    27. __Z25PlayerLoadSceneFromThreadiRKNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEER18AwakeFromLoadQueue [PlayerLoadSceneFromThread?S(int, undefined?N?&)]@http://localhost:50085/Development/WebGL_Build.js:1521350:119
    28. __ZN18LoadSceneOperation19IntegrateMainThreadEv [LoadSceneOperation::IntegrateMainThread()]@http://localhost:50085/Development/WebGL_Build.js:1526268:119
    29. __ZN14PreloadManager26UpdatePreloadingSingleStepENS_21UpdatePreloadingFlagsE [PreloadManager::UpdatePreloadingSingleStep?N()]@http://localhost:50085/Development/WebGL_Build.js:1524734:31
    30. __ZN14PreloadManager16UpdatePreloadingEv [PreloadManager::UpdatePreloading()]@http://localhost:50085/Development/WebGL_Build.js:1524840:79
    31. __Z10PlayerLoopbbP10IHookEvent [PlayerLoop(bool, bool, IHookEvent?*)]@http://localhost:50085/Development/WebGL_Build.js:1523202:43
    32. __ZL8mainloopv [mainloop()]@http://localhost:50085/Development/WebGL_Build.js:2672238:32
    33. dynCall_v@http://localhost:50085/Development/WebGL_Build.js:4445824:30
    34. dynCall@http://localhost:50085/Development/WebGL_Build.js:302:43
    35. http://localhost:50085/Development/WebGL_Build.js:9539:28
    36. runIter@http://localhost:50085/Development/WebGL_Build.js:11130:17
    37. Browser_mainLoop_runner@http://localhost:50085/Development/WebGL_Build.js:9535:33
    I dont have a clue what it should be ... any hint please ?
     
  48. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
    Short answer: No.
    The Game Servers communicate with the Master Server to let it know how full games are and how busy the server is. Without that, it won't work.
    How many CCU do you expect? The 500 CCU subscription includes overage, so if you suddenly lots more players, you can adjust your subscription. With 100 CCU, you cover approximately 40k monthly active users, which should generate a bit of income, hopefully.
     
  49. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
    Can you post this in it's own thread in our forum please?
    Are you using FindFriends() to see who is online? Or Facebook's API?
    It might take a moment before the system updated itself about B being online again. If you use FindFriends(), call it in ~10sec interval and allow it a while.
     
  50. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,607
    I don't understand the details. Some abort? Could be an issue in Unity's export or related how this client behaves exactly. Might be something took too long and got aborted?
    Please report this as issue to Unity. They might be able to tell you more.[/code][/QUOTE]
     
unityunity