Quantcast
Channel: Photon Unity Networking (PUN) — Photon Engine
Viewing all 8947 articles
Browse latest View live

Adjust ServerSettings at runtime?

$
0
0
My game connects to a central update server at startup, and I would like to be able to adjust any necessary Photon settings via this update server. For example, if Photon Cloud goes down I would like to be able to host my own server and temporarily point all my released games to it.

For some reason, Photon's ServerSettings seem to be stored as static members of a nonstatic serialized ScriptableObject. How do I access and change them at runtime? The code I have:
public static ServerSettings PhotonServerSettings = (ServerSettings)Resources.Load (Path.GetFileNameWithoutExtension (NetworkingPeer.serverSettingsAssetPath), typeof(ServerSettings));
PhotonServerSettings.DefaultMasterPort = 5005;

Results in this error:
error CS0176: Static member `ServerSettings.DefaultMasterPort ' cannot be accessed with an instance reference, qualify it with a type name instead

(2018.3) Add Component not working

$
0
0
Hi, when after updating to 2018.3 i can no long add any components...... So after removing and reinstalling PUN its working again. delete this. I get this errror: ArgumentException: An element with the same key already exists in the dictionary. System.Collections.Generic.Dictionary`2[System.String,System.String].Add (System.String key, System.String value) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:404) UnityEditor.AdvancedDropdown.AddComponentDataSource.GetMenuDictionary () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/AddComponent/AddComponentDataSource.cs:70) UnityEditor.AdvancedDropdown.AddComponentDataSource.RebuildTree () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/AddComponent/AddComponentDataSource.cs:17) UnityEditor.AdvancedDropdown.AddComponentDataSource.FetchData () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/AddComponent/AddComponentDataSource.cs:10) UnityEditor.AdvancedDropdown.AdvancedDropdownDataSource.ReloadData () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/AdvancedDropdown/AdvancedDropdownDataSource.cs:22)

Problems connecting to room

$
0
0
So I create two instances of my game. One within the unity editor, and one as its own build. When I try to join a room however both clients create their own room instead of joining the other open one. This used to work before but suddenly has not. Does anyone have any suggestions for what it could be? Both instances are being played on the same computer.

pun 2 automatically disconnected in android device

$
0
0
hello, i am facing this issue when demo app run on android device.It works fine in another device and also in editor but not on my device Connect() to 'ns.exitgames.com' (InterNetworkV6) failed: System.Net.Sockets.SocketException (0x80004005): Network is unreachable.

How to call OnDisconnect?

$
0
0
Seemingly ALL methods related to this behavior is deprecated, docs doesn't cover this meaningfully (Says its derived from IPunCallbacks which doesn't exist, and I'm deriving from MonoBehaviourPunCallbacks which holds behavior to connect, so why not the onDisconnect?)

I've tried OnFailedToConnect, OnFailedToConnectToMasterServer, OnDisconnectedFromServer etc. all those that pun suggests, and the OnDisconnectedFromPhoton seemingly just doesn't exist. I have just downloaded the most recent version of pun?

Using Photon Bolt with Ludiq Bolt

$
0
0
I'm trying to get started with Photon Bolt using Ludiq Bolt. Anyone have some screenshots/video/tips on how to get started using these two bolts together?

Weird issue in unity arises that it breaks prefab connection

$
0
0
The error suffenly came when I was working with photon view + photon transform view Assertion failed on expression: '!(m_Object.find(fileID) != m_Object.end() && m_Types[m_Object.find(fileID)->second.typeID].GetPersistentTypeID() != objectPersistentTypeID)' UnityEditor.EditorApplication:Internal_CallGlobalEventHandler() Now if I remove photonview it removes the error but without photon view the project won't work as it is a multiplayer game. Unity:- 2018.3.0f2

Has anyone tried to serialize Oculus Avatar?

$
0
0
Hi all, I'm just ramping up on both Oculus Avatar and Photon. I've been reading the getting started tutorial. Is it possible to use the PhotonView scripts to automatically serialize an Oculus avatar?

Handling Disconnects

$
0
0
Hello. Our game has the following flow for determining if all players ( between 5 and 8 ) are ready: When each player is ready, they will set a custom property indicating they are ready and the call an rpc which tells all clients to update their loading ui and the master increments a counter of how many players are ready. The master then checks if all players are ready. here is the code: private void SetupComplete() { ExitGames.Client.Photon.Hashtable playerProperties = new ExitGames.Client.Photon.Hashtable(); playerProperties.Add(Strings.PLAYER_LOAD_STATUS, true); PhotonNetwork.player.SetCustomProperties(playerProperties); photonView.RPC("RemoteCallForSetupComplete", PhotonTargets.AllBufferedViaServer); } [PunRPC] public void RemoteCallForSetupComplete() { //add call here to update player loading tabs if (LoadingScreen.GetInstance() != null) { LoadingScreen.GetInstance().UpdatePlayerLoadingTabs(); } if (PhotonNetwork.isMasterClient) { ++playerSyncCount; if (PhotonNetwork.offlineMode || (playerSyncCount >= PhotonNetwork.playerList.Length)) photonView.RPC("SetupCompleteForEveryOne", PhotonTargets.AllBufferedViaServer); } } This code works fine. However we need to handle the situation where a player disconnects. To do that we use the OnPhotonPlayerDisconnected callback. From OnPhotonPlayerDisconnected, the master client calls the following function to check if all players are now ready as the disconnecting player may have been the only one we were waiting for: public void MasterCheckSetupCompleteAfterPlayerDisconnect() { if (LoadingScreen.GetInstance() != null) { LoadingScreen.GetInstance().UpdatePlayerLoadingTabs(); } Debug.LogError("Player count : " + playerSyncCount + " actual count " + PhotonNetwork.playerList.Length); if (PhotonNetwork.offlineMode || (playerSyncCount >= PhotonNetwork.playerList.Length)) photonView.RPC("SetupCompleteForEveryOne", PhotonTargets.AllBufferedViaServer); } Here is the issue. What if the player who disconnected has already completed setup? In this case I should decrement the playerSyncCount. The issue is I am not 100% sure what the best way to do that is. Here are possibilities 1) I check the Strings.PLAYER_LOAD_STATUS for the disconnecting player to see if it is true. This seems like a good idea. I just wonder if there might be an edge case where this won't have updated right after the player disconnects? 2) Modify the code, so the master client doesn't rely on an rpc call to indicate players are done loading, and rather periodically check the player properties hash table to compare number of players with loaded players Please advise

photonView.Owner.NickName produces NullReferenceException error

$
0
0
Kind of flabbergasted by this. I followed that beginner tutorial two months ago that has a section for displaying player names and it worked fine. I've been coding away on other stuff and I came back to it, commented it out, and tried to change it. I get "NullReferenceException - Object reference not set to an instance of an object" any time I try to use photonView.Owner.NickName now. I uncommented the original code and it produces the error now too. Example of code I tried to run that gives the error: string test = photonView.Owner.NickName; Original code followed this tutorial: https://doc.photonengine.com/en-us/pun/v2/demos-and-tutorials/pun-basics-tutorial/player-ui-prefab Line that produces an error now is: playerNameText.text = this.target.photonView.Owner.NickName;

Not connecting Photon Master server

$
0
0
Hi Guys, We have integrated the photon and has 100CCU plan. Recently game is not connecting to mast server more frequently. Its not giving call back "public virtual void OnConnectedToMaster()" in failure scenario. Could you please help us in tracking this issue. Below are the Photon game settings in our game for your reference. Protocol selected -- Tcp
        PhotonNetwork.autoJoinLobby = false;   
        gameObject.AddComponent();
        PhotonNetwork.networkingPeer.DisconnectTimeout = 30000;
        PhotonNetwork.networkingPeer.SentCountAllowance = 10;
        PhotonNetwork.networkingPeer.QuickResendAttempts = 4;

        PhotonNetwork.ConnectToRegion(CloudRegionCode.us,"1.0");

InvalidCastException: Cannot cast from source type to destination type (Photon version : 1.91)

$
0
0
Hi, i got this error when using WebGl only , my game works fine with no errors (standalone PC Build) , but when i use WebGl build and test i got this : InvalidCastException: Cannot cast from source type to destination type. NetworkingPeer.AlmostEquals (System.Object one, System.Object two) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:4567) NetworkingPeer.DeltaCompressionWrite (System.Object[] previousContent, System.Object[] currentContent) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:4416) NetworkingPeer.OnSerializeWrite (.PhotonView view) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:4302) NetworkingPeer.RunViewUpdate () (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:4118) PhotonHandler.Update () (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:165) i don't know is this Unity or Photon issue and i don't know what data else i can provide here , tell me and i will edit this question with new data

Child Status of gameobject is only visible by local client

$
0
0
Hello, so I used photonnetwork.instantiate one of my prefabs and then I turn it into a child. This code works but only for the local client even when I have photon view attached to my prefabs and animation+transform view. Any suggestions because I'm pretty lost with this one Snips of my code + setups. Most of the Photon Views in the scripts are set to be public rather than private https://imgur.com/ecCAGKd https://imgur.com/a/aG0JSJ2

RPC problems

$
0
0
I am trying to use RPC's to send messages, moves, etc. in my game. I have a network script object in my game with a photon view component. Also worth knowing is I am using PUN classic because I am more comfortable with it. My code looks like this: PhotonView photonView = PhotonView.Get(this); photonView.viewID = PhotonNetwork.AllocateViewID(); string message = messageInputField.text; photonView.RPC("chatMessage", PhotonTargets.Others, message); I get an error that says: Received RPC "chatMessage" for viewID 1001 but this PhotonView does not exist! Was remote PV. Owner called. By: 1 Maybe GO was destroyed but RPC not cleaned up. Would greatly appreciate any help. Thanks.

CustomProperties constantly updates outside of Update function, in master client?

$
0
0
This only happens on my masterclient, I'm unsure if it's a bug or I misunderstood how custom properties work. I load up all my playerproperties in start, and when I comment out this method I can change the color in the inspector again without problems: public void UploadPlayerProperties(PhotonView pv) { Hashtable props = new Hashtable() { { "colorRval", "" + PlayerColor.r }, { "colorGval", "" + PlayerColor.g }, { "colorBval", "" + PlayerColor.b }, { "playerName", "" + PlayerName }, { "playerState", "" + PlayerState }, { "spawnTileID", "" + ""}, { "currentTileID", "" + ""} }; pv.Owner.SetCustomProperties(props); } So to clarify, I can't hange the color in inspector, as it will keep reloading the color I set originally. It doesnt even matter whether I load them in or not, as soon as I call this method, despite the fact I have it in my start method, It works fine on every other client, but masterclient though, and if I load it up in Unity not being master client, it allows me to change the color of my character.

Switch from a Relay service to a dedicated Enterprise

$
0
0
Hello, We are considering to choosing photon PUN to make our multiplayer. The question are: -When I use PUN, do I need to write a server separately from the client code and then upload it in photon public cloud? - Does PUN allows some kind of back-end logic? Maybe with plugins? Or I am forced to use the enterprise cloud? if yes what is the cost? it's bad I can't have a sort of idea of the costs. - I know that PUN scales well in case of many users. But let's say that the games becomes popular and i need an authoritative control check on the servers. I would like to make the least effort to switch from a relay to an authoritative solution. I don't want to code more and how the transition will happen? how the traffic will be moved to the enterprise cloud seamlessly? let's say tomorrow I decide to go for the authoritative architecture, I don't want to lose my player or stop them playing. How can I do the transition? - Maybe should I start immediately with the enterprise solution? but again at which costs? I like that free CCU plan for PUN so if I start paying only when I have many clients! does the enterprise cloud ave a similar price plan? Thank you!

BOT AI Players State of the Art

$
0
0
Hello, We are considering PUN for our multiplayer game. In the forum I read different threads with different solutions for BOTS. -Some people say one should use the plugins but are they released for the public cloud in the end? -Some people managed to modify the users IDs for the bots... What is the current state of the art? Has Exit game updated the API or released something on this? What is the best way to make Bots player for a racing game? How to split the AI on players? How to manage the MasterClient disconnection and so on...If one player is playing against all local bots how do you manage to see if is not cheating? Thank you!

How do you create multiple, long lived rooms similar to popular mobile chess games?

$
0
0
Hello! I'm exploring Photon and I'm struggling to find a way that I can create a matchmaking scenario that is similar to the chess.com online mobile experience. If you're unfamilar with that, consider this:
  • User taps "New Game"
  • User sets some options for that game
  • User taps "Create Game"
  • The user does not immediatly join the game (unless they have the first turn) because its asynchronous multiplayer and needs to wait until an opponent joins that game and takes the first turn.
  • A list of active games is displayed for the user to see
  • A User can repeat this multiple times to have multiple games going with different/similar options
I'm struggling to see how I can:
  1. Create multiple rooms per user at the same time
  2. Create empty rooms, or at least have the player joined in the room and actually participate in the game once an opponent is found
  3. Have the rooms/games live while an opponent is found (the user may close the app until a push notification is received that an opponent is ready/ their turn"
Thanks in advance for your advice!

Camera sync problem

$
0
0
Hello ! :) I am using a firstpersoncontrols that I found on the asset store unfortunately I have problems. When I'm alone in the room I have no problem but when a second player joins I have problems: - When I move the camera of the first player moves the camera of the second player. - If I move the camera of the second player the camera of the first player moves. I was careful to use the "Is.Mine", on the script that manages the controls it works but the script that manages the camera does not work. Here is the script in question: I added to the original script the "Is.Mine" in the start and the update. If anyone could help me that would be great! Thank you in advance :)

How to make all clients to be disconnected when MC leave the room or disconnect from photon?

$
0
0
Hello @JohnTube How are you? I 've got many great answers from you. Thank you. I changed my plan and now I've got a new question. I have one master client which has a game script for the normal clients. The normal clients have a normal client-side script. And the master client creates the room. So if there is no room created by a master client, the client's can't see any created room. And also, if the master client leaves the room, the other clients should be disconnected. But they don't disconnect. Is there any solution? I think there is no method for destroying the room... But I think there are many solutions for this :) Please kindly give me a help. Thanks
Viewing all 8947 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>