Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Photon Unity Networking

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

  1. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    I am sorry to read you are running into randomly happening crashes.

    The stack trace shows how much deeper Unity goes into it's own Instantiate methods and for me, this indicates the issue is not directly caused by PUN but it certainly is caused by some race condition between instantiation and level loading.
    If the objects refer to some code in the scene, this may be related but essentially, I have no idea what the actual issue is.

    What I'd suggest:
    • Update Unity. You use 2019.3.0f6 but there have been many many updates since. Better even: Those updates are for a LTS version and should only fix issues, so you have a lot to gain with low risk.
    • Set IsMessageQueueRunning. You are spot on with the usage and implications. It will pause dispatching of incoming messages. Instantiation will be delayed until after the scene is loaded, which should be good in any case. The Master Client not running into this issue might be due to loading the scene first, then instantiating the networked objects.
     
    utkarshdwivedi3997 likes this.
  2. utkarshdwivedi3997

    utkarshdwivedi3997

    Joined:
    Aug 11, 2017
    Posts:
    22
    Thank you for the quick response! You are right in advising to upgrade to the LTS version. My team recently upgraded to Unity 2020 and had a really bad experience with extremely slow load times, so we rolled back to 2019.3.0f6 and haven't upgraded since. I think it would be worth it to try another upgrade to a 2019 LTS version.

    I've added the IsMessageQueueRunning changes as we discussed. There is no guaranteed way for us to know if this helped with the crash issue, except to wait it out and just keep working on the game as we normally do. We tend to see at least one crash on scene load every other day, so if we don't see such a crash for a substantial time, we'll consider it fixed.

    Thanks again for your help! :)
     
    tobiass likes this.
  3. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    We released another update: v2.34.

    v2.34 (26. July 2021)
    Changed: The PhotonView.Owner and .Controller for "room PhotonViews" will be changed properly whenever the Master Client switches. Room PhotonViews are identified by IsRoomView (which checks CreatorActorNr == 0).
    Changed: PUN needs to exit play mode in Editor, if there is a recompilation (due to code change, etc) to prevent running into endless NullReferenceExceptions and a flood of other errors. As the connection can't be held up after recompile, this is no big step back. The log will include a hint why the client exited playmode.
    Changed: The PhotonNetwork constructor creates a NetworkingClient (in Editor) to avoid exceptions due to possible recompilation.
    Changed: PhotonNetwork.StaticReset was running as RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad) but will run earlier now, using AfterAssembliesLoaded.
    Updated: Library to 4.1.6.4. More details in changes-library.txt.
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    We released a tiny PUN 2.34.1 update:

    v2.34.1 (28. July 2021)
    Updated: PhotonNetwork.PunVersion to "2.34.1" now. The previous version accidentally used "2.33.3" still.
    Updated: For Unity 2021, the obsoltete CompilationPipeline.assemblyCompilationStarted got replaced with CompilationPipeline.compilationStarted.
     
  5. danger726

    danger726

    Joined:
    Aug 19, 2012
    Posts:
    167
    Hi @tobiass,

    I'm now getting a null deref exception after upgrading to PUN 2.34.1. Previously I was on 2.31 without any problems (sorry, I haven't had a chance to test the versions in between to narrow it down).

    In my scene I have a gameobject, and in its Awake() I add a PhotonView component to it (this happens on all clients). Then:

    1) On the master client, in IMatchmakingCallbacks.OnJoinedRoom() I allocate a view ID by calling PhotonNetwork.AllocateViewID( true ) and assign it to the PhotonView.

    2) When another client joins the room, in IInRoomCallbacks.OnPlayerEnteredRoom(Player networkPlayer) on the master client, I raise an event (using PhotonNetwork.RaiseEvent(...)), passing the PhotonView's view ID through the event content.

    3) When the joining client receives this event in IOnEventCallback.OnEvent(EventData photonEvent) I assign the view ID (passed in through EventData.CustomData) to the PhotonView. This causes Photon to register the PhotonView (via the ViewID property's "set").

    This has all been working fine for a long time, but now after the upgrade I'm getting a null deref on the joining client.

    The client now receives the PunEvent.OwnershipUpdate event from the master client (presumably raised in PhotonNetwork.OwnershipUpdate(...)) before the PhotonView has been registered via step 3) as described above.

    Here's the callstack where the exception happens:

    NullReferenceException: Object reference not set to an instance of an object
    Photon.Pun.PhotonNetwork.OnEvent(EventData photonEvent) (PhotonNetworkPart.cs:2415)
    Photon.Realtime.LoadBalancingClient.OnEvent(EventData photonEvent) (LoadBalancingClient.cs:3356)
    ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback(StreamBuffer stream) (PeerBase.cs:898)
    ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands() (EnetPeer.cs:565)
    ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands() (PhotonPeer.cs:1863)
    Photon.Pun.PhotonHandler.Dispatch() (PhotonHandler.cs:221)
    Photon.Pun.PhotonHandler.FixedUpdate() (PhotonHandler.cs:147)


    Right after this, the client receives my event, and the PhotonView is registered. Everything seems to work OK from then on, so thankfully this issue doesn't prevent me from testing the game.

    I'm not sure if I'm doing something particularly weird or non standard to cause this problem. Perhaps I could avoid all this by having the PhotonView component permanently part of the gameobject in the scene (rather than adding it in Awake(), passing view IDs around, and so on). The reason I do it this way is because some build configurations of my game don't include PUN.

    I don't have time to dig into this further right now, but let me know if you have any suggestions or questions, thanks!
     
    Last edited: Aug 16, 2021
  6. Alex_Heizenrader

    Alex_Heizenrader

    Joined:
    May 16, 2019
    Posts:
    40
    So I have some photonViews I want to take over simply with photonView.TransferOwnership(PhotonNetwork.LocalPlayer); but they are on objects that might be disabled temporarily. Doing this causes an error in the ownership transfer. Is there a way to solve this? It seems like the photonView List PUN keeps track of is only of current enabled photonViews and it fails to do the transfer. Is there a manual way to do it or some solution?

    Thanks.
     
  7. Mordus

    Mordus

    Joined:
    Jun 18, 2015
    Posts:
    174
    What kind of licensing will it have if all i want is the networking library and I want to host my own dedicated servers and not use yours. Particularly the ability to distribute my dedicated server so people can host their own servers.
    (Really hoping the answer isn't a per-server monthly fee)
     
  8. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    Sorry for the late reply here. Vacation time...

    @danger726, I hope you are one of the developers who also posted the problem on our forum and got help.
    The problem is most likely that you don't pause the message queue when entering rooms and loading scenes / assets. This messes with the order of actions to take to align all clients to know the same networked objects.
    In short: Make sure to not dispatch incoming messages while you load/setup the networked scene. If you do, some received events may execute before a client knows the event's target PhotonView.
    Of course, we will need to improve the handling and reaction to this situation...

    @Alex_Heizenrader, I checked the code and didn't see any issues with disabled PhotonViews. As I don't have a repro case yet, maybe you could let us know which version you use and how it fails exactly. The relevant parts of an error message would help.

    @Mordus, we don't offer this kind of redistribution of Photon Server at all, sorry. If you are sure you only need local-network multiplayer, the Photon Server is probably not needed. MLAPI, Mirror and others support this.
     
  9. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    I submitted a small update for PUN 2 to fix an issue and update the Photon library. As usual it's recommended to backup the project and update.

    v2.35 (24. August 2021)
    Changed: CheckConnectSetupXboxOne() to allow AuthOnceWss and Datagram Encryption (GCM mode). It will set ExpectedProtocol and EncryptionMode silently. Datagram Encryption is only possible with a native plugin.
    Changed: Interest Culling in UtilityScripts/Culling/.
    Added: Rate limiting for interest group changes per second. No matter what the algorithm tells us, it makes sense to not change interest groups more than 4-6x per second.
    Changed: The GetActiveCells method to sort the "nearby" part of the cells list. This allows us to not change interest groups if just the order changed (due to "nearby" calculation, that could happen).
    Changed: The scene view grid now displaces the various area-indexes for cells that overlap (root, node and leaf).
    Note: Overall, the algorithm to select cells is just a quick showcase. It should avoid unsubscribing groups one by one and also avoid subscribing nearby groups one by one (while moving only along one axis of the areas).
    Fixed: A potential NullReferenceException for OwnershipUpdate events. If the PhotonView is unknown, this gets logged now. This is caused most frequently by loading scenes (or initializing them) without pausing the incoming message queue (dispatch). If ownership changed for objects, the Master Client will let new players know this but that failed, if the joining client didn't know the objects yet.
    Updated: Realtime API. Check out changes-realtime.txt.
    Updated: Library to 4.1.6.5. More details in changes-library.txt.
     
  10. danger726

    danger726

    Joined:
    Aug 19, 2012
    Posts:
    167
    Hi @tobiass, thanks for your reply. Not me I'm afraid, I didn't post to your forum, must've been someone else.

    I think I'm doing as you describe. Right before calling SceneManager.LoadSceneAsync(...) I set PhotonNetwork.IsMessageQueueRunning to false, and I have a handler registered with the SceneManager.sceneLoaded event in which I set PhotonNetwork.IsMessageQueueRunning back to true again.

    The problem I'm having does seem to be to do with event ordering though, i.e. the joining client receiving the PunEvent.OwnershipUpdate event before receiving the event I sent from the master client that sets the PhotonView's view ID.

    If you can make things more robustly handle unregistered PhotonViews that would be great. If not, I'll see if I can figure out a solution on my end.

    Cheers.
     
  11. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    If the event with the ViewID is cached, the joining player gets the cached events first and in order of them being cached. The OwnershipUpdate is an event that's sent by the Master Client on join (only to the joining player). This makes it a "live" event, which is always being dispatched after all cached events. So that order is not a problem.

    Do you manage setting your ViewIDs yourself? Is any of the clients sending those ViewIDs?
    Maybe the objects with PhotonView are not setup and listed at the very moment sceneLoaded gets fired. Maybe you should delay enabling the message queue for a frame (to allow Awake, etc, unless that already ran).

    The latest PUN 2.35 was changed to not fail with a NullReferenceException but log an error instead. However, this kind of conceals the problem: The client receives and event with info for PhotonViews which can't be found (yet).
    Right now, I don't have an idea how to make this more robust. I need to know more about your use.

    You can also mail that info: developer@photonengine.com
     
  12. miha4406jp

    miha4406jp

    Joined:
    Apr 8, 2021
    Posts:
    9
    Hello, I'd like to use existing game objects, not prefabs, so guest player could control my game objects. How should I do it then? PhotonView and PhotonTransformView updates it only for guest, but host can't see any changes.
    Namely, this: https://forum.unity.com/threads/pun-photonview-problem.1162403/
    Is it possible?
     
  13. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    Objects in the scene may have PhotonViews.
    You can put PhotonViews on objects that exist but then have to make sure everyone knows which object has which PhotonViews and ViewIDs on those. We call that Manual Instantiation.
     
  14. miha4406jp

    miha4406jp

    Joined:
    Apr 8, 2021
    Posts:
    9
    I get "Null reference exception" on trying PhotonNetwork.AllocateViewID() on game object w/o PhotonView component.
    And I get "AllocateViewID() can't be used for PhotonViews that already have a viewID." on game object with it.

    Ah, and I can't use word "CustomManualInstantiationEventCode" for some reason.
     
    Last edited: Aug 28, 2021
  15. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    That's expected. You have to do call it for objects with PhotonView.
    To fix the issue with CustomManualInstantiationEventCode, have a look at the compiler logs and look up how to fix that. This is not a PUN related topic, really.
     
  16. danger726

    danger726

    Joined:
    Aug 19, 2012
    Posts:
    167
    Yes, I manage setting the ViewID. The master client sends the ViewID (that it allocated) to the joining client via a custom photon event. However, the client is receiving this event after the OwnershipUpdate event, hence the problem.

    I grabbed 2.35 and yes, now I'm getting the logged error instead of a null ref. If I can't figure out a solution, I'll try making an example project to recreate the issue and send it for you to look at.
     
  17. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    It makes sense to cache the events, that announce viewIDs. This way, they are sent in-order before everything else, when someone joins.
    Use the RaiseEventOptions.CachingOption and set it to AddToRoomCache. You can clean this up if needed, as described in this doc:
    https://doc.photonengine.com/en-us/pun/v2/gameplay/cached-events

    Hope that helps.
     
  18. miha4406jp

    miha4406jp

    Joined:
    Apr 8, 2021
    Posts:
    9
  19. Leonid

    Leonid

    Joined:
    Aug 20, 2013
    Posts:
    85
    Hello!
    I have a bunch of objects (sceneObjects and player-owned) and I need to get owner's local time on the other clients before they receive data in OnPhotonSerializeView.
    I dont want to use an obvious solution (send local time in OnPhotonSerializeView for each object), because It will consume a lot of traffic.
    Instead I would like to pass local time through some single object with photonView (lets call it "TimeSyncer") and then just refer to it on onter objects.
    The problem is - I'm not sure if TimeSyncer sends and receives data in OnPhotonSerializeView before other objects.
    Is there any way to:
    1) ensure that TimeSyncer sends and receives data in OnPhotonSerializeView before others?
    2) pass the data before OnPhotonSerializeView being called on every object in some other way?
    Thank you!
     
  20. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,701
    I haven't tried this, so I'm only spit balling here, but you could set the player's local time in a CustomPlayerProperty when each client player is created and then track the amount of time they've been connected.

    From those two values you should be able to constantly calculate the local time for each player without sending any network traffic other than the initial CustomPlayerProperty setting.
     
  21. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    OnPhotonSerializeView has 2 parameters: PhotonStream stream, PhotonMessageInfo info.
    The second contains the (server) time of sending for that update. Compare that to the local PhotonNetwork.ServerTimestamp to figure out how long (approximately) the message was on it's way.

    As network jitter will fluctuate, it should make more sense to figure out how old the individual message is.
     
  22. Leonid

    Leonid

    Joined:
    Aug 20, 2013
    Posts:
    85
    Thanks a lot!
    So there is no built-in way to control the serialization order.
    I was thinking about similar solution - pass local time on initialization and then just add time intervals each time OnPhotonSerializeView is called.
    However, I need higher precision, so using ServerTime is not an option.
    I'll keep looking :)
     
  23. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
  24. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    We just updated PUN 2 in the store.
    No breaking changes but a few changes for the "Native Socket Plugins" for consoles.

    v2.36 (20. September 2021)
    Updated: Realtime API. Check out changes-realtime.txt.
    Updated: Library to 4.1.6.6. More details in changes-library.txt.
     
    dan_ginovker likes this.
  25. MrGreenish

    MrGreenish

    Joined:
    Oct 20, 2019
    Posts:
    28
    I have a Unity project with PUN2. I don't want to set "PhotonNetwork.AutomaticallySyncScene" to "true" because the player can choose to stay in the lobby or load the level (at any time).

    Join room -> Click Load a new scene-button -> spawn player

    Issue : The first player to join can see all other players who will join later. The second player to join can't see the first player but they can see all those who will join later. The third can't see the first or second and so on.

    Desired result: I want the game objects that are already on the server to sync for new players who join the room later so all previous players are visible. I want everything to work as if PhotonNetwork.AutomaticallySyncScene = true EXCEPT I don't want the players who join the room later to automatically load the game-scene just because the room owner has done so. They need the option to wait and click join whenever desired.
     
  26. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    When players join a room, they get all the instantiate events from existing characters and all updates for existing objects. On the other hand, when players change scenes, this usually destroys there characters (unless you flag the game objects as DontDestroyOnLoad).
    To not reinvent the wheel, you'd probably have to avoid destroying the objects that should be existing.
    I don't have a solution that will work out of the box but I'd probably load both scenes and make sure only one is visible. Or you'd place the lobby in a location in the scene, so there is no overlap? Then you'd have to properly teleport players when they enter the game scene.
     
    MrGreenish likes this.
  27. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    We released a smaller update with a few fixes:

    v2.37 (27. September 2021)
    Added: CustomType deserialization length checks.
    Added: PhotonNetwork.EnableCloseConnection which defaults to false. This is a breaking change: Only if you set this to true, CloseConnection will work anymore.
    Updated: Library to 4.1.6.7. More details in changes-library.txt.
     
    dan_ginovker likes this.
  28. dan_ginovker

    dan_ginovker

    Joined:
    Jun 13, 2021
    Posts:
    41
    Hey @tobiass, is there any place to view changes-library.txt or changes-realtime.txt without downloading Photon from the Asset store? I found PhotonEngine's Github but it seems abandoned
     
  29. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    Sorry, the file is only in the zip / package.
     
  30. utkarshdwivedi3997

    utkarshdwivedi3997

    Joined:
    Aug 11, 2017
    Posts:
    22
    @tobiass I'm happy to report that this fixed our crash! After making this fix in July we haven't seen this specific crash, and even after launching the game we haven't received any crash reports on this matter. Thanks again for all the help on this!

    That said, I wanted to confirm something from you about a rare issue we're encountering. We're doing teams matchmaking in our game pretty much the exact same way it is described on the Photon PUN2 website here under the teams matchmaking section. This works great for us, except in some rare occasions, one of the non-master clients fails to join their team leader.

    After debugging this I think it may be happening because even though the
    PhotonNetwork.FindFriends(new string[1]{ leaderUserId }); function manages to find the leader, it sometimes finds the leader when they aren't in a room yet. The code uses the FriendInfo.IsInRoom property to find out if the user is in a room yet, and if not, we wait inside a coroutine for this value to become true, but it seems to never become true, even though the leader clearly gets in a room and other members of the team also join him properly.

    Our basic code is set up like this:

    1. Repeatedly call PhotonNetwork.FindFriends()
    2. As soon as a OnFriendListUpdate(List<FriendInfo> friendList) callback is received with the leader's information, STOP calling PhotonNetwork.FindFriends(). This does not check if the leader is in a room yet or not.
    3. Join the leader's room. However, if the user is not in a room, wait for the IsInRoom property to become true.

    I think the issue here is that we stop firing PhotonNetwork.FindFriends(), but wait for a boolean property (IsInRoom) to update, and I think I may have misunderstood how this works? Do I need to call the FindFriends function again, and keep calling it until I receive a callback with the leader's FriendInfo.IsInRoom = true? My assumption is that all those properties are updated only when the callback is fired. Am I correct?
     
  31. MrGreenish

    MrGreenish

    Joined:
    Oct 20, 2019
    Posts:
    28
    Thanks for replying but it wont solve my issue.
    User 1 joins a room. User 1 clicks "Join game" at any chosen time and loads the game scene.
    User 2 joins the same room. User 2 clicks "Join game" at any chosen time and loads the game scene.
    User 1 can see user 2 but user 2 can't see user 1.

    I need to instantiate user 1 on user 2 as well. With RPC calls or any way as long as it's working. If that means reinventing the wheel, then so be it. I tried a few things but I can't get it to work. I can't be the only person who ran into this problem, but I can't find an answer/tutorial anywhere.
     
  32. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    Yes, this is the case. The FindFriends response provides the info and the info itself won't update otherwise.
    Please poll it with the lowest frequency you can accept (in doubt, we'd have to come up with a limit, which we don't want to).
    Good to read the confirmation that your crash issue is gone for good!

    Unity usually destroys all existing objects in the hierarchy, when loading a scene, which seems to be the case for user 2. If you load scenes with PUN 2, it will destroy existing objects.
    One solution I see is: Use DontDestroyOnLoad(obj) to keep the player's character around. Or load the scene additively (not destroying existing objects).
     
    utkarshdwivedi3997 likes this.
  33. MrGreenish

    MrGreenish

    Joined:
    Oct 20, 2019
    Posts:
    28
    I don't instantiate anything on the server when the player joins the room. I only spawn a Player-gameobject when the user loads the level scene. There is nothing that needs to be saved from the previous scenes. The problem is that Player-gameobjects that are already spawned in the level scene don't instantiate or sync automatically for users who join later on.
     
  34. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    You probably should make sure that no events (instantiates and rpcs) are dispatched while you load. This can be done with IsMessageQueueRunning.
     
  35. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    Updated PUN 2 to v2.38, just to release a new Photon library (v4.1.6.9) with some improvements.
     
    Johan_Liebert123 likes this.
  36. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    Just updated PUN 2 to v2.39. This has a new Photon library with important stability improvements, a fix for the Chat API on consoles and last but not least this:

    Everyone should update. This has no breaking changes compared to recent versions.
     
    dan_ginovker likes this.
  37. afavar

    afavar

    Joined:
    Jul 17, 2013
    Posts:
    31
    Does Fusion support matchmaking features currently?
     
  38. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    Yes, matchmaking features were added to Fusion already.
     
  39. dpcco

    dpcco

    Joined:
    Nov 25, 2018
    Posts:
    2
    How can i use my own server in fusion? Current server sdk does not support fusion.
     
  40. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    This is not supported for v1.
    The Fusion servers themselves .. can be hosted anywhere.
     
  41. Nest_g

    Nest_g

    Joined:
    Jun 18, 2019
    Posts:
    33
    Hi, the price changed from 100 ccu for 60 months for $95 to 100 ccu for 12 months for $95? the price up 5x?
     
  42. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    Yes, sadly the earlier price didn't work out at all.
    PUN 2 Plus is often included in the Asset Store sales, so look out for a discount...
     
  43. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    We released a new version for PUN 2:

    v2.40 (22. November 2021)
    Fixed: Unity 2021.2 support. PhotonEditorUtils.IsPrefab now uses the correct prefab stage utility for Unity 2021.2 and up.
    Changed: PhotonHandler.Dispatch is now catching exceptions. It will count them but only provide the first one's callstack (to avoid log spamming).
    Note: While the Photon lib caught exceptions in v4.1.6.10, that has not been a good solution. This new approach can be changed in source and is more flexible overall.
    Changed: On Xbox, the peer classes no longer assume a native socket plugin exists. This was setting the UDP implementation to null in some cases, which failed to connect.
    Updated: Library and Realtime to 4.1.6.11. More details in the change logs.
     
  44. unity_TMhR7IoONty-HA

    unity_TMhR7IoONty-HA

    Joined:
    Dec 26, 2020
    Posts:
    4
    Hello ı have one problem the character does not stand still, it moves constantly, sometimes it flies how can ı solve ıt
     
  45. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
  46. SpySloth

    SpySloth

    Unity Technologies

    Joined:
    Jan 21, 2022
    Posts:
    1
    hi, maybe you could help me out. I'm trying to set up Photon Fusion. It's all good but I can't find a way to debug it painlessly as client disconnects after a few seconds after breakpoint was hit. Tried to increase Connection Timeout in Network Project Settings but that didn't affect anything. Any idea what I might be missing?
     
  47. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,941
    You likely use the Public Photon Cloud. This has a server-side timeout which can't be changed (as it's shared). Without setting this at least, you won't be able to pause Fusion for longer than a few seconds. I also can't say if it supports pausing the direct connection for debugging.
    The best place to ask about Fusion is our Photon Engine Discord, very likely. You can join it via the Photon Account Dashboard.
     
    SpySloth likes this.
  48. PRfsJay

    PRfsJay

    Joined:
    Apr 22, 2021
    Posts:
    13
    Good Morning, I have a question if nobody minds answering it. If a person makes a game and it has a limited number of connections, like 30 but you have hundreds of people trying to connect, does PUN2 paid create make multiple shards on one server to satisfy all users wanting to play? I know very little about how it works, but my assumption is that if you create a game and it has a limit of 30 people, you get one server that you pay for access to for your app and you have only the ability to have the example 30 at one time even if their are many more people trying to play.

    I hope that makes sense.

    Thank you for your time and attention.
     
  49. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,701
    Photon has the concept of rooms which I believe would be the equivalent of what you term as shards.

    So assuming that you set the max players per room to 30, you can have your users connect in such a way they will join a random room that has less than 30 players connected and if there are no rooms with available space, a new one will be created for them to join, which other players can then randomly join.
     
  50. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    787
    what limits you most is the cap of messages per seccond, I believe its 500. So if you're syncing positioin of a player at a rate of 10 messages per sec. You could have 50 players.
    ANd not sure if 500 is per account or per room. What I do is to limit to 10 players per room and that works pretty decent.
    There was some code. can´t recall the name, which had an asset on asset store where he explained how to sync a ***load of AI.

    While I purchased never needed it nor had the time but I believe that in a float or in a vector 3 you could pack enough for sincing a lot of stuff because at meter level 2 decimal is cm level which is more than enough and same for rotation.
     
unityunity