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

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

RTS - One time information sharing

$
0
0
Hey, so I'm very new to pun and I started with a simple RTS like prototype. So far I have player movement working with just a transform view. (Not typical for RTS, but whatever) The map for the game is procedural. So I want the master client to generate a seed and share it with the others. This works right now. I do it with OnPhotonSerializeView. In there I do something like this:
if (PhotonNetwork.IsMasterClient)
{
    stream.SendNext(seed);
}
else
{
    if (seed == int.MinValue)
    {
        seed = (int)stream.ReceiveNext();
        GenerateMap(seed);
        DisplayMap();
    }
}
Which works. But I don't want to send the map seed all the time. Which I think happens. Right? So how could I share the seed only when a new player connects? And further on. If I add building placement. How do I share the info that I placed a building one time to all the players? Overall: How do I share an information only one time. And maybe: How do I share a information to a new joined player? Sorry if the question is hard to understand. But please point me in the right direction. Thanks everyone (:

Observe option in Photon View

$
0
0
I am new to Photon. Would someone tell me the difference of the followings in the Observe option in the Photon View: 1. off 2. Reliable Delta Compressed 3. Unreliable 4. Unreliable on Change Many thanks.

Destroy objects with same Owner

$
0
0
Hey guys, I just did the Photon2 tutorial, but there is a problem I cant solve. When a new player joins the game, the character is instantiated twice, one is acting normal and also controllable, but the other just flies on its spawnpoint. The player can only controll the first one. Question: So I want simply to destroy all disturbing objects, until there is only one left, that the owner has. It would help if I could destroy in some way the character that is not controllable. I am not experienced at all and couldn't find something in the internet to solve this. I would really appreciate if somebody could help me.

LAN for exhibition purposes

$
0
0
Hi there Is there any way to run a server locally and have clients connect to the local server? Our game is 3v3 and we want to be able to run the game on a local network at exhibitions since the internet is generally unreliable at exhibitions. All the devices will be on the same network (iPads) and there will be a windows/mac PC available to host 'the server'. Just wondering what exactly I need to 'host' - is there a version of photon cloud that we can run locally? Leaving the rest of our game intact? (maybe with the exception of the connection code - no need for name server right? we just connect directly to the machine which has a static local IP)

HELP: Can't add. Size exceeded

$
0
0
This occurs for all clients after entering loading the game scene with multiple players, here's the full log: Exception: Can't add. Size exceeded.
  at Photon.Pun.PhotonNetwork+SerializeViewBatch.Add (System.Collections.Generic.List`1 viewData) [0x00034] in C:\Users\adam\OneDrive\Documents\ProjectStarfighter\Assets\Photon\PhotonUnityNetworking\Code\PhotonNetworkPart.cs:1387 
  at Photon.Pun.PhotonNetwork.RunViewUpdate () [0x00123] in C:\Users\adam\OneDrive\Documents\ProjectStarfighter\Assets\Photon\PhotonUnityNetworking\Code\PhotonNetworkPart.cs:1464 
  at Photon.Pun.PhotonHandler.LateUpdate () [0x00025] in C:\Users\adam\OneDrive\Documents\ProjectStarfighter\Assets\Photon\PhotonUnityNetworking\Code\PhotonHandler.cs:146 
Here's my code for joining / creating rooms: StartAsHost() and JoinServer() are both called from buttons, connecting is done beforehand. I'm not sure what to do from here or what the error even means.

What is the difference between the concept of Lobby and Room in Photon Unity Networking?

$
0
0
Hello, I'm currently on networking game development. I want to know the difference between the Lobby and Room in PUN. Does every players always have to join specific room through Lobby? and is it required that the Lobby exist only one in each App? If possible, I beg you guys to give me super detailed explanation about my question.

HELP: Can't add. Size exceeded.

$
0
0
Hello guys, I'm really new to PUN so please be kind with me :D I'm getting the "Can't add. Size exceeded." error some seconds after starting the room with 1 additional player and I don't really get where I'm causing this. Can someone please help me and tell me what causes such an error and where I should look into ? Thank you very much !!!

How to allocate a ViewID for a network manager? (PUN 2.7)

$
0
0
Hi, I have a PhotonNetworkManager MonoBehaviour with a few PunRPC functions. For the RPC to work I need a PhotonView. I'm adding the PhotonView at runtime (in OnEnable) because I want to keep my prefabs network API-agnostic. I use AllocateSceneViewID() on the master client after creating a room and then send that ViewID to the other players (using RaiseEvent) so that their network manager has the same ID and RPC calls work. This works fine, but only for the first room created. If I exit the room and create another one, AllocateSceneViewID() fails:
AllocateSceneViewID() can't be used for PhotonViews that already have a viewID. 
Is there a better way of handling this, or is the solution not to use RPCs and use events instead? Thanks!

Photon and Playfab - PhotonNetwork.playerName Hacking

$
0
0
Hey guys, I'm using the Playfab Authentication to Login with this and send a Token to Photon for a safe Player-Login. I programmed my whole game already using Photon and everything is working perfect, and I use the Other PlayerNames to make Kills, damage and so on, the mechanics for my game are already done. Now what I'm thinking of: Is using PhotonNetwork.playerName the right solution? How can I make sure a player who logged in with Playfab will have his DisplayName as PhotonNetwork.playerName and another Player who hacked my unity client is not allowed to use another Player's DisplayName as his PhotonName? Greetings, Dario

Offline mode issue

$
0
0
I am in the process of updating to PUN to v2, but noticed an issue with offline mode. I am getting an error when changing the local player name. Cannot send op: 252 Not connected. PeerState: Disconnected I have made a simple repro:
void Start() { PhotonNetwork.OfflineMode = true; PhotonNetwork.LocalPlayer.NickName = "Offline Player"; } public override void OnConnectedToMaster() { PhotonNetwork.CreateRoom("Offline Room"); }

Looking for Game setup advice with PUN

$
0
0
Hi there, I am fairly new to PUN2. However I have been coding with unity for several years. I'm finding myself kinda logic stuck at the moment with PUN2. Perhaps PUN might not fit the needs of my project. So I'm going to do a brief TLDR of my concepts that I'm stuck on. For simplicity sake we will call it a 2d project with a 4x design. The majority of game play will happen through the UI. The main map with location objects as "Cities". Each player can see the entire game map and the cities they control in full. Players should be presented a "State" of the map with limited enemy player intel. Players should not be aware of majority of other players actions. As such Player 1 should not know that player 2 is building units at his city. Some actions will reveal a full update of the enemy object. Some will only provide some intel IE: Sending an army to the city should reveal the full state. Where as a spy mission might only discover some unit details. Can I perform these kind of features with pun? The system seems to be more geared for constant streaming updates. For things like 3d position ect.. I have allot of the features working for single player. So I know my project sounds a bit intense. But I need to get a good multiplayer solution that isn't being depreciated. Once I get the foundation I can approach the next hurdle of converting what I have/can.

what are some Best Tutorials to learn photon PUN 2?

$
0
0
Any Paid tutorials will be great on udemy. Where can I find some of the best tutorials for Photon-2 this year? As Unet being Deprecated by Unity Photon is Claiming to be the Number One Platform To create Realtime Multiplayer GAMES. Recently Photon Changed The implementation in Photon 2 with better and optimized and well structured code. As being the number one still lack in documentation.

What could have happened?

$
0
0
I'm learning and made a simple project on 3/15. It instantiates a cube as a player after connecting to room. It worked and every new instance of the .exe I launch, I see another cube. Having learned it, I went to integrate PUN2 to my actual game. It also worked but a few days ago, all of a sudden I don't see other players any more. Debugging shows every instance thinks itself as the master client. After not making progress debugging further the past few days, I remembered the sample project's exe I built 3/15. So I go back to launch it and it also doesn't show other players any more. The last modifed date of this .exe is 3/15, meaning I didn't change anything to cause this behavior. Could my account have somehow changed?

PUN classic duplicate photonview id found error

$
0
0
PhotonView ID duplicate found: 1. New: View (0)1 on RemoteAvatarCopy(Clone) (scene) old: View (0)1001 on LocalAvatarCopy(Clone) . Maybe one wasn't destroyed on scene load?! Check for 'DontDestroyOnLoad'. Destroying old entry, adding new. how is this possible, it even says in the error message that they have different ids

Photon OnPremise Server

$
0
0
Hi, I am supporting the development of a multiplayer application in, of course, Unity. Up to this point, the devs have been using Photon Cloud on the backend for multi-player and voice. I'll have plenty of questions about implementing voice, but I am concerned now with an exception being thrown when we attempt to connect to the new OnPremise server. So far, we've changed the connection settings in the PhotonServerSettings Inspector window. We aren't using name server, are leaving the appid realtime and voiceid to random numbers, setting a version number = 1, running in the background and setting the IP and port numbers for the OnPremise server. I should add that when I run the Stardust test client, it is able to connect to the server just fine with 3 to 5 connections, and i am using loadbalancing though I only have 1 box hosting the server. Here is the exception being thrown. Any ideas would be greatly appreciated: IndexOutOfRangeException: Index was outside the bounds of the array. ExitGames.Client.Photon.Protocol16.SerializeDictionaryHeader (ExitGames.Client.Photon.StreamBuffer writer, System.Object dict, System.Boolean& setKeyType, System.Boolean& setValueType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol16.cs:1048) ExitGames.Client.Photon.Protocol16.SerializeDictionaryHeader (ExitGames.Client.Photon.StreamBuffer writer, System.Type dictType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol16.cs:1038) ExitGames.Client.Photon.Protocol16.SerializeDictionaryHeader (ExitGames.Client.Photon.StreamBuffer writer, System.Object dict, System.Boolean& setKeyType, System.Boolean& setValueType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol16.cs:1082) ExitGames.Client.Photon.Protocol16.SerializeDictionary (ExitGames.Client.Photon.StreamBuffer dout, System.Collections.IDictionary serObject, System.Boolean setType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol16.cs:1030) ExitGames.Client.Photon.Protocol16.Serialize (ExitGames.Client.Photon.StreamBuffer dout, System.Object serObject, System.Boolean setType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol16.cs:627) ExitGames.Client.Photon.Protocol16.SerializeObjectArray (ExitGames.Client.Photon.StreamBuffer dout, System.Collections.IList objects, System.Boolean setType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol16.cs:1000) ExitGames.Client.Photon.Protocol16.Serialize (ExitGames.Client.Photon.StreamBuffer dout, System.Object serObject, System.Boolean setType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol16.cs:619) ExitGames.Client.Photon.Protocol16.SerializeHashTable (ExitGames.Client.Photon.StreamBuffer dout, ExitGames.Client.Photon.Hashtable serObject, System.Boolean setType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol16.cs:1017) ExitGames.Client.Photon.Protocol16.Serialize (ExitGames.Client.Photon.StreamBuffer dout, System.Object serObject, System.Boolean setType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol16.cs:604) ExitGames.Client.Photon.Protocol16.SerializeParameterTable (ExitGames.Client.Photon.StreamBuffer stream, System.Collections.Generic.Dictionary`2[TKey,TValue] parameters) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol16.cs:527) ExitGames.Client.Photon.Protocol16.SerializeOperationRequest (ExitGames.Client.Photon.StreamBuffer stream, System.Byte operationCode, System.Collections.Generic.Dictionary`2[TKey,TValue] parameters, System.Boolean setType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol16.cs:442) ExitGames.Client.Photon.EnetPeer.SerializeOperationToMessage (System.Byte opCode, System.Collections.Generic.Dictionary`2[TKey,TValue] parameters, ExitGames.Client.Photon.EgMessageType messageType, System.Boolean encrypt) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:1095) ExitGames.Client.Photon.EnetPeer.EnqueueOperation (System.Collections.Generic.Dictionary`2[TKey,TValue] parameters, System.Byte opCode, ExitGames.Client.Photon.SendOptions sendParams, ExitGames.Client.Photon.EgMessageType messageType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:936) ExitGames.Client.Photon.PhotonPeer.SendOperation (System.Byte operationCode, System.Collections.Generic.Dictionary`2[TKey,TValue] operationParameters, ExitGames.Client.Photon.SendOptions sendOptions) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1505) Photon.Realtime.LoadBalancingPeer.OpRaiseEvent (System.Byte eventCode, System.Object customEventContent, Photon.Realtime.RaiseEventOptions raiseEventOptions, ExitGames.Client.Photon.SendOptions sendOptions) (at Assets/DownloadedAssets/Photon/PhotonRealtime/Code/LoadbalancingPeer.cs:864) Photon.Realtime.LoadBalancingClient.OpRaiseEvent (System.Byte eventCode, System.Object customEventContent, Photon.Realtime.RaiseEventOptions raiseEventOptions, ExitGames.Client.Photon.SendOptions sendOptions) (at Assets/DownloadedAssets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:1603) Photon.Pun.PhotonNetwork.RaiseEventInternal (System.Byte eventCode, System.Object eventContent, Photon.Realtime.RaiseEventOptions raiseEventOptions, ExitGames.Client.Photon.SendOptions sendOptions) (at Assets/DownloadedAssets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2193) Photon.Pun.PhotonNetwork.SendInstantiate (Photon.Pun.InstantiateParameters parameters, System.Boolean sceneObject) (at Assets/DownloadedAssets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2523) Photon.Pun.PhotonNetwork.NetworkInstantiate (Photon.Pun.InstantiateParameters parameters, System.Boolean sceneObject, System.Boolean instantiateEvent) (at Assets/DownloadedAssets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2447) Photon.Pun.PhotonNetwork.Instantiate (System.String prefabName, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation, System.Byte group, System.Object[] data) (at Assets/DownloadedAssets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2297) NetworkMesherHelpers.NetworkModel.GenerateNetworkMesh (System.String nodePath, System.String linkPath, System.String statPath, System.String alertPath) (at Assets/Scripts/NetworkMesherHelpers/NetworkModel.cs:603) GameManager.OnJoinedRoom () (at Assets/Scripts/Management/GameManager.cs:28) Photon.Realtime.MatchMakingCallbacksContainer.OnJoinedRoom () (at Assets/DownloadedAssets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3348) Photon.Realtime.LoadBalancingClient.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/DownloadedAssets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2476) ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PeerBase.cs:633) ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands () (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:545) ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1473) Photon.Pun.PhotonHandler.FixedUpdate () (at Assets/DownloadedAssets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:130)

Ownership transfer

$
0
0
Hi! I have the following situation: Player loses connection, becomes inactive and server waits for that player's reconnect. And I'm trying to get that disconnected player controlled by AI or something like that until he/she reconnects. So the master client takes care of everything, but only after playerTtl time expires, since only then player view is owned by scene. So the question is: is there a way to get ownership of the disconnected player view? I've read something about Ownership Transfer and I know I shoud choose TakeOver option for the desired PhotonView. But I don't get what to do next and I'm not sure if that ownership transfer would succeed since the current owner is disconnected. Also, what will happen if that player reconnects? Will he be the owner of that view again? P.S. I'm sorry for my English

PUN2 - PhotonNetwork.ConnectToRegion(sm_serverRegion); doesn't work...

$
0
0
If I use PhotonNetwork.ConnectUsingSettings(); I get a connection to EU server, and all seems to work just fine, but when I use PhotonNetwork.ConnectToRegion("eu"); I get the following error message: OperationResponse 230: ReturnCode: 32767 (Invalid application id). Parameters: {} Server: NameServer Address: ns.exitgames.com:5058 UnityEngine.Debug:LogError(Object) Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:1848) Photon.Realtime.LoadBalancingClient:OnOperationResponse(OperationResponse) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:1922) ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(StreamBuffer) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PeerBase.cs:616) ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:545) ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1473) Photon.Pun.PhotonHandler:FixedUpdate() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:116) ... I'm using Unity 2018.3.10f1 and PUN 2.9 (Photon lib 4.1.2.10)...

Unity Photon Handle Match Data

$
0
0
Hello, I'm building a multiplayer game that has instanced battles (find match matchmaking). I have the matchmaking finished and it throws the 6 (3v3) players into an empty room using PhotonNetwork.LoadLevel('Game'); This shows 6 empty rooms. What I need: I need help spawning the players while also keeping the game data for each particular match organized in some way (file, scriptable object, etc). This is useful for the matches themselves as well as stuff like match history later on.

I would appreciate any help. Thanks

How can I make a player reconnect to a game when his internet connection is slow or disconnected?

$
0
0
Hey i just want to know, how can i make a player still be connected in the game when his internet fluctuates. Lets say if two players are playing against each other in an 8 ball pool game and player1 lost internet connection, how can we give time to him to reconnect without just kicking him out of the room? Thanks in advance!
Viewing all 8947 articles
Browse latest View live


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