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

Error CS0104

$
0
0
Hi I made a new project using the last version of unity (2018.1.0f2), imported the last version of PUN (Free) 1.90 and I got 11 errors:
error CS0104: `Hashtable' is an ambiguous reference between `System.Collections.Hashtable' and `ExitGames.Client.Photon.Hashtable'

What can I do about it ?

Thanks in advance.

The observed monobehaviour XXX of this PhotonView does not implement OnPhotonSerializeView()!

$
0
0
so no idea why im getting this error
sorry for the bold just trying to split code and reg typing
The observed monobehaviour (FredPS(Clone)) of this PhotonView does not implement OnPhotonSerializeView()!
UnityEngine.Debug:LogError(Object)
PhotonView:ExecuteComponentOnSerialize(Component, PhotonStream, PhotonMessageInfo) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:515)
PhotonView:SerializeComponent(Component, PhotonStream, PhotonMessageInfo) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:434)
PhotonView:SerializeView(PhotonStream, PhotonMessageInfo) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:327)
NetworkingPeer:OnSerializeWrite(PhotonView) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3493)
NetworkingPeer:RunViewUpdate() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3414)
PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:132)

its not even calling a script. just the base game object
so im quite confused

i use the following
void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting)
{

stream.SendNext(health);
}
else
{

health = (float)stream.ReceiveNext();
}
}
is all im sending at the moment

but yet i still get this error i fires this error 3 times and because of this i cant seem to update my health values





[PunRPC]
public void GetShot(float damage)
{
health -= damage;
if (healthless "lessthan" = 0 && photonView.isMine)
{
if (RespawnPlayer != null)
RespawnPlayer(3f);

PhotonNetwork.Destroy(gameObject);
}
}


ii call the punrpc within this

void TempShooting()
{



RaycastHit hit;

if (Physics.Raycast(firePos.transform.position, firePos.transform.forward, out hit, Mathf.Infinity))
{

Debug.DrawRay(firePos.transform.position, firePos.transform.forward, Color.red);
if (hit.transform.tag == "Player")
{
hit.transform.GetComponent().RPC("GetShot", PhotonTargets.All, GunDamage);
}




}
}

and on update i have my input for firing ...

if (photonView.isMine)
{

if (Input.GetKeyDown(fire))
{
TempShooting();
}


}

Any Help on this would be great thanks !

Player automatically leaves a room without user consent/acknowledgement.

$
0
0
I'm trying to implement a turn based game using Photon. In my game when a player enters a room he waits for the second/other player to join the room. If both players are now in the room the game then spawns some game objects in the scene. Just to check if everything is working I didn't implement anything afterwards. Things get spawned and appear in both clients' windows as expected. The problem is after a few seconds, the player to first enter/join a room automatically leaves the room followed by the other player. In this case the player doesn't opt to leave the room but somehow he leaves the room. How do I solve this?

Billiard implementation

$
0
0
Hello!
I am trying to make turn based game similar to billiard using UNITY and PUN..
I would like to transfer initial strike only and then run physics on both machines. I already have a little prototype.

I disabled Physics2D.autoSimulation and I trigger shot using RPC with initial force. Then I run simulation using Physics2D.Simulate with constant 0.04f step on both machines. I only take shots once every Rigidbody2D is sleeping.

The thing is that in MOST cases everything works fine. Unfortunately for whatever reason from time to time things go completely out of sync.

I am testing Mac vs Android which may be the cause (different platforms), but I suspect it could go wrong even within Android platform itself.

I also tried to transmit transform positions and rotations but results are a little bit too jerky for my liking.

Any suggestions? Is my approach even possible?

Best regards!

Send a message or RPC to single client?

$
0
0
I haven't been able to find anything on this in the documentation, so if I've missed something I'd appreciate being pointed in the correct direction. Is it possible to send an RPC or raise an event to only a single client? This exists for MasterClient, which is great, but I don't see a way to send an event to a single client without spamming the room. Am I missing something obvious?

Event for scene objects getting their initial OnPhotonSerializeView?

$
0
0
So I've got a scene that contains some spawn points. Only one player can occupy a spawn point and the spawn point's occupation status gets updated in it's OnPhotonSerializeView.

I'm dealing with my player instantiation inside the OnJoinedRoom callback, but I've noticed that when it gets called, the spawn points in the scene haven't yet received a OnPhotonSerializeView call to update their occupation status, so it leads to players occupying the same point because it appears unoccupied when OnJoinedRoom is called.

The workaround I'm using is I put the instantiation stuff into a coroutine with a delay that gets started in OnJoinedRoom. With a .5 second delay, the spawn points seem to get updated in time, but with network congestion, this method seems like it could lead to problems.

Is there a built-in way to know when scene objects have been updated so you can move along with logic that requires them to have their current states accurate?

Is it bad to subscribe many interest groups?

$
0
0
Is it bad to subscribe many interest groups or does a bigger byte array (120 subscribed groups) increases the traffic? (I don't ask if that traffic is caused by other players sending things in these groups of course..) And does every player know what other players subscribed? Because each player updates his interest groups in my game at about 30 times per second. I appreciate any help

How make a game like fortnite with this plug in

$
0
0
Hi everyone,
We have a question for choose the online plugin for our game, it is based on fortnite. Players reach number between 60-100, we have to synchro near object, life object, bullets, player movement... all this without lag. What is the best plug in ?

Battle royale game

$
0
0
hello to all, I am writing to ask you if it was possible to build a battle royale through photon PUN. I already had experience with photon so I think I know how to move, now I'll explain how I thought about making the game, I would need to know what you think:
- 40/60 players per room;
- these can build (as fortnite) and the built objects will be instantiated locally so as not to have the photon view, or if they must necessarily have the sync frame rate reduced to a minimum;
- the prioettili seems to me that they must necessarily have the photon view even if I'm not sure.
The main question is this:
Can photon synchronize 40-60-80 player without laggare?
I thought maybe to insert a collider big enough for each player and when this collide with another collider increases its frame rate in order to be synchronized at best when two players are close, otherwise your frame rate is reduced to a minimum.
Is there any course or good tutorial for the photon servers and how to manage them better for a similar game?
Thanks so much

problem importing assets PhotonNetwork with Photon Chat

$
0
0
after importing the 2 I get this error
Does anyone have a solution?

Receive data as input to Matlab Simulink (in computer) using Photon cloud from unity3d googleVR

$
0
0
I am running a Google vr unity application on my phone. I need to send some variable from the unity application to Matlab Simulink being run on the Computer. I was planing to upload the variable values to Photon cloud using PUN and receive the values Matlab Simulink. I need help at how to receive data from photon cloud to Matlab Simulink

Having a PhotonView ID duplicate found error when using JoinRoom or JoinRandomRoom

$
0
0
So here's the line of error I'm having:
"PhotonView ID duplicate found: 1001. New: View (0)1001 on FPSController old: View (0)1001 on FPSController . Maybe one wasn't destroyed on scene load?! Check for 'DontDestroyOnLoad'. Destroying old entry, adding new."

The problem happens whenever I join a room using: PhotonNetwork.JoinRoom(roomName); or PhotonNetwork.JoinRandomRoom();

I use Manual Instantiation approach as indicated by a sample code in:
https://doc.photonengine.com/en-us/pun/current/gameplay/instantiation

I do control the scene loading though, but the thing is I don't have an FPSController that's tagged "DontDestroyOnLoad()", those things are cleaned whenever the scene is unloaded.

------

And then here comes a confusing part, if I use: PhotonNetwork.JoinOrCreateRoom(roomName);
things works as intended, and I don't get a duplicate PhotonView Id error. I can switch back on forth on my scenes with my players and it just works smoothly.

Anyone have any clue as to why JoinRoom() and JoinRandomRoom() is throwing such errors?

Connection from MasterClient to clients not working

$
0
0
Since yesterday when I try to run an RPC from the MasterClient to All it doesn't do anything and i can't seem to figure why.

To give you a context of how my interaction between the Masterclient and All clients, I have a sequence minigame, where the player has the 4 directional arrows (up, right, down, left) and he has to press them in the order shown in the sequence.
Step-by-step:
- Client 1 clicks on the minigame
- RPC from Client 1 to All clients to open the minigame window
- RPC from Client 1 to the Master Client to generate a sequence (to ensure that all clients see the same sequence)
- RPC from the Master Client to All clients with the generated sequence to create the minigame(This is the one that stopped working out of nowhere)

Also whenever two clients connect the console just fills up with the error quoted below.

"NullReferenceException: Object reference not set to an instance of an object
PhotonTransformView.OnPhotonSerializeView (.PhotonStream stream, PhotonMessageInfo info) (at Assets/Plugins/Photon/Photon Unity Networking/Plugins/PhotonNetwork/Views/PhotonTransformView.cs:123)
PhotonView.ExecuteComponentOnSerialize (UnityEngine.Component component, .PhotonStream stream, PhotonMessageInfo info) (at Assets/Plugins/Photon/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:532)
PhotonView.SerializeComponent (UnityEngine.Component component, .PhotonStream stream, PhotonMessageInfo info) (at Assets/Plugins/Photon/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:457)
PhotonView.SerializeView (.PhotonStream stream, PhotonMessageInfo info) (at Assets/Plugins/Photon/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:352)
NetworkingPeer.OnSerializeWrite (.PhotonView view) (at Assets/Plugins/Photon/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:4092)
NetworkingPeer.RunViewUpdate () (at Assets/Plugins/Photon/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3961)
PhotonHandler.Update () (at Assets/Plugins/Photon/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:164)"

Anyone has a clue why this is happening? Is it happening to anyone else?

RPC creates object that seemingly needs one layer for each player in the room.

$
0
0
I am working on a top-down, multiplayer game (~15 players per match) that uses ray casting for shooting. I am working on an ability where a player can deploy a portable shield that will appear for a few seconds and then disappear. The player who deployed the shield is able to shoot through it, but enemies cannot (think Overwatch style shields). When a player deploys the shield, an RPC is sent out to all clients saying to deploy a shield at position P and rotation R. The shield itself is not using a photonView, each client is responsible for deploying/destroying the shield.

Right now I am putting the shield on an "IgnoreRaycast" layer for the player who deployed the shield, and a "Shield" layer for all others. The problem I am running in to is that on enemy players devices, the shield that I deployed is put on the "Shield" layer, so my photonView player object on their device is visually hitting the shield when it shouldn't be.

A possible solution that I have thought of is to create a separate layer for every player/team that is in each match. Given that Unity only allows us to create 24 layers for our games, and that there will be ~15 players/teams per match in my game, this doesn't seem like the correct solution.

If anyone has solved this in their games I would love to hear how! Thanks!

Some confusion as to Photon Serialization

$
0
0
I'm a bit confused as Photon seems to not be permitting a serialization that this page implies should be legitimate by default. The table specifies that array (array of type T, T[]) is legal. I can confirm this by using an array of a primitive as an argument for an RPC call with no issue. The table also specifies that
T-type can be any of the types listed in this table except byte.
Cool. The table specifies that Dictionary<K,V> is legal, and once again I can confirm this by sending a Dictionary of two primitive types over an RPC call without issue. However, when attempting to combine this information in order to send Dictionary<K,V>[], the following error will always occur


IndexOutOfRangeException: Array index is out of range. ExitGames.Client.Photon.Protocol16.SerializeDictionaryHeader (ExitGames.Client.Photon.StreamBuffer writer, System.Object dict, System.Boolean& setKeyType, System.Boolean& setValueType) ExitGames.Client.Photon.Protocol16.SerializeArray (ExitGames.Client.Photon.StreamBuffer dout, System.Array serObject, Boolean setType) ExitGames.Client.Photon.Protocol16.Serialize (ExitGames.Client.Photon.StreamBuffer dout, System.Object serObject, Boolean setType) ExitGames.Client.Photon.Protocol16.SerializeObjectArray (ExitGames.Client.Photon.StreamBuffer dout, System.Object[] objects, Boolean setType) ExitGames.Client.Photon.Protocol16.Serialize (ExitGames.Client.Photon.StreamBuffer dout, System.Object serObject, Boolean setType) ExitGames.Client.Photon.Protocol16.SerializeHashTable (ExitGames.Client.Photon.StreamBuffer dout, ExitGames.Client.Photon.Hashtable serObject, Boolean setType) ExitGames.Client.Photon.Protocol16.Serialize (ExitGames.Client.Photon.StreamBuffer dout, System.Object serObject, Boolean setType) ExitGames.Client.Photon.Protocol16.SerializeParameterTable (ExitGames.Client.Photon.StreamBuffer stream, System.Collections.Generic.Dictionary`2 parameters) ExitGames.Client.Photon.Protocol16.SerializeOperationRequest (ExitGames.Client.Photon.StreamBuffer stream, Byte operationCode, System.Collections.Generic.Dictionary`2 parameters, Boolean setType) ExitGames.Client.Photon.TPeer.SerializeOperationToMessage (Byte opc, System.Collections.Generic.Dictionary`2 parameters, EgMessageType messageType, Boolean encrypt) ExitGames.Client.Photon.TPeer.EnqueueOperation (System.Collections.Generic.Dictionary`2 parameters, Byte opCode, Boolean sendReliable, Byte channelId, Boolean encrypt, EgMessageType messageType) ExitGames.Client.Photon.PeerBase.EnqueueOperation (System.Collections.Generic.Dictionary`2 parameters, Byte opCode, Boolean sendReliable, Byte channelId, Boolean encrypted) ExitGames.Client.Photon.PhotonPeer.OpCustom (Byte customOpCode, System.Collections.Generic.Dictionary`2 customOpParameters, Boolean sendReliable, Byte channelId, Boolean encrypt) LoadBalancingPeer.OpRaiseEvent (Byte eventCode, System.Object customEventContent, Boolean sendReliable, .RaiseEventOptions raiseEventOptions) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/LoadbalancingPeer.cs:779) NetworkingPeer.OpRaiseEvent (Byte eventCode, System.Object customEventContent, Boolean sendReliable, .RaiseEventOptions raiseEventOptions) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1012) NetworkingPeer.RPC (.PhotonView view, System.String methodName, PhotonTargets target, .PhotonPlayer player, Boolean encrypt, System.Object[] parameters) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3804) PhotonNetwork.RPC (.PhotonView view, System.String methodName, .PhotonPlayer targetPlayer, Boolean encrpyt, System.Object[] parameters) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:2998) PhotonView.RPC (System.String methodName, .PhotonPlayer targetPlayer, System.Object[] parameters) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:646) MatchProxy.registerTeam (System.Collections.Generic.Dictionary`2[] team) (at Assets/Scripts/Battle/MatchProxy.cs:29) Match.startMatch () (at Assets/Scripts/Battle/Match.cs:74) ServerProxy.startMatch () (at Assets/Scripts/Battle/Client/ServerProxy.cs:29) System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232) System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115) NetworkingPeer.ExecuteRpc (ExitGames.Client.Photon.Hashtable rpcData, Int32 senderID) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2985) NetworkingPeer.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2578) ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (System.Byte[] inBuff) ExitGames.Client.Photon.TPeer.DispatchIncomingCommands () ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () PhotonHandler.Update () (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:157)


Original RPC Call:
Match.m.photonView.RPC("registerTeam", PhotonNetwork.masterClient, (object)team);


Original RPC Reception:
[PunRPC] public void registerTeam(Dictionary<string, string>[] team, PhotonMessageInfo info) { Match.m.registerTeam(info.sender.ID, team); }

According to the table, this should work, as arrays should work with any other type in the table (according to the description), and Dictionaries are in the table. So what's up? Am I misusing/misunderstanding the RPC, is the serialization page inaccurate, or is there a bug I should be aware of?

I'm trying to connet photon cloud using PEER class (not LoadBalancingClient)

$
0
0
Hi
I want to try how much can connect to Photon Cloud Enterprise (this is private photon cloud right?)
I'm trying to use STARDUST client to how we determine what CCU is fine.

As youwe know you can connect to photon cloud to master
loadBalancingClient.ConnectToRegionMaster("us");

Unfortunately, STARDUST is not using LoadBalancingClient but using PEER class.

so how can I connect to photon cloud using PEER.
(or photon sdk C# not PUN)

Thank you


NCommand.CreateAck excaption

$
0
0
Occasionally, our players would report an network issue and the following call stack would appear in the output_log.txt.

System.IndexOutOfRangeException: Array index is out of range.
at ExitGames.Client.Photon.NCommand.CreateAck (System.Byte[] buffer, Int32 offset, ExitGames.Client.Photon.NCommand commandToAck, Int32 sentTime) [0x00000] in :0
at ExitGames.Client.Photon.EnetPeer.QueueOutgoingAcknowledgement (ExitGames.Client.Photon.NCommand readCommand, Int32 sendTime) [0x00000] in :0
at ExitGames.Client.Photon.EnetPeer.ReceiveIncomingCommands (System.Byte[] inBuff, Int32 dataLength) [0x00000] in :0
at ExitGames.Client.Photon.NCommand.CreateAck (System.Byte[] buffer, Int32 offset, ExitGames.Client.Photon.NCommand commandToAck, Int32 sentTime) [0x00000] in :0
at ExitGames.Client.Photon.EnetPeer.QueueOutgoingAcknowledgement (ExitGames.Client.Photon.NCommand readCommand, Int32 sendTime) [0x00000] in :0
at ExitGames.Client.Photon.EnetPeer.ReceiveIncomingCommands (System.Byte[] inBuff, Int32 dataLength) [0x00000] in :0
Exception while reading commands from incoming data: System.IndexOutOfRangeException: Array index is out of range.
at ExitGames.Client.Photon.NCommand.CreateAck (System.Byte[] buffer, Int32 offset, ExitGames.Client.Photon.NCommand commandToAck, Int32 sentTime) [0x00000] in :0
at ExitGames.Client.Photon.EnetPeer.QueueOutgoingAcknowledgement (ExitGames.Client.Photon.NCommand readCommand, Int32 sendTime) [0x00000] in :0
at ExitGames.Client.Photon.EnetPeer.ReceiveIncomingCommands (System.Byte[] inBuff, Int32 dataLength) [0x00000] in :0

OnPhotonPlayerConnect/Disconnect

$
0
0
Hi all,

I just wanted some clarification on the parameters associated with:

public override void OnPhotonPlayerConnected(PhotonPlayer newPlayer)
public override void OnPhotonPlayerDisconnected(PhotonPlayer otherPlayer)

The players set a particular key and value in the Lobby (category, string[]) via SetCustomProperties.
MasterClient will create a room, gets their key and value out and I can use said data.
When a player joins the room, I would expect that newPlayer contains that incoming player's CustomProperties, correct?
But when I try getting their key and/or value, it comes out as null.

However, that same incoming player can show me their key and value if I check locally via PhotonNetwork.player.CustomProperties...

Is there something I'm missing about those callbacks? I figured it would've been relatively straightforward if local PhotonPlayers can access their own CustomProperties and using the above method would sync their CustomProperties to the server.

I checked the doc but it's relatively sparse about the use of the parameters: https://doc-api.photonengine.com/en/pun/current/interface_i_pun_callbacks.html#a14eede4f84e088008e59fe63efb8775d

I'd appreciate any insights and/or inputs. Otherwise, I'm just gonna do this the old RPC fashion to sync up the data.
Thanks!
Andy

How to get scene load progress when using photonnetwork.loadlevel

$
0
0
Hi,

I use photonnetwork.loadlevel to load my scenes and I have it set up so that when the master client switches the other players in the room automatically switch as well.

Usually in unity to do a progress bar for loading a scene you would use async load and then check operation progress to see how far you had got in order to update your loading progress.

With photonetwork.loadlevel I'm not aware of how I would get the scene progress as there doesn't appear to be any way of checking load progress?
I'm aware photon doesn't have an async load so how do I go about getting the scene load progress for the master and the various joined hosts so they can be presented with some time line type information on how long they will need to wait for the scene to load?

Is it not possible to use interest groups when playing from one pc?

$
0
0
Interest groups are working for me with 2 players but not with 3 or more. The first and second player can see the third player and the third player can see the other ones. But the third player is not capable of sending via interest groups (except 0) with raise event. There is no error in console when trying to send something via interest group 105 as the third player with the unity engine. There is no error in the console when having the other perspective (first and second player). I'm starting the game 3 times on my pc. It doesn't matter whether I'm starting the build 3 times or using the editor. It doesn't matter whether the third player is started via build or via the editor. Since its the same script on every player and its working for the first and second perfectly with interest groups it isn't the usual mistake like don't writing PhotonNetwork.SetInterestGroups(106, true); or don't writing
RaiseEventOptions Raise = RaiseEventOptions.Default;
Raise.InterestGroup = 106;
PhotonNetwork.RaiseEvent(106, postemp, true, Raise);
or dont using the event code corretly. The third player can send messages with Raise.InterestGroup = 0; or with the right target actors just fine. I'm trying to find a mistake by my self since a few days and I even created a new project to see if the same error would occur and it did. Is it not possible to use interest groups when playing from one pc? I'm thankful for any help.
Viewing all 8947 articles
Browse latest View live


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