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

Constant disconnects! Help!!

$
0
0
Hello,

I'm using Photon PUN with Unity in WebGL firefox browser.

Photon keeps disconnecting when the game starts playing a video streamed from another server.

To help diagnose the issue, I displayed the photon debug information on the screen which tells when it last receive an ping from the photon server. As soon as the video starts streaming, you can see the time when it last receive a ping starts going up and up until it disconnected because it never gets a ping after the video starts playing.

It very strange that when the video starts streaming, photon can no longer communicate with the server which then causes the disconnect.

But while the video is streaming, my code can easily communicate with my remote server using plain ordinary WWW, i can even download pics using plain old WWW while streaming the video, but somehow photon cant communicate with its server. Only god knows what they are doing in their code!

Anybody seen this issue, i need this fixed because my game will be useless if it keeps disconnecting!!!

How can i contact technical people at photon about this issue? this is very important!!

Thanks


pun 1.80 - after calling Disconnect() the networkingPeer.State stays in Disconnecting indefinitley

$
0
0
My game is a multiplayer game, but have also a single player mode. After I upgraded to pun 1.80 I started to experience the following problem:

When a single player game is started this code is executed:
PhotonNetwork.Disconnect();
PhotonNetwork.offlineMode = true;
After the single player game finished (couple of minutes) and the player goes back to the main menu the PhotonNetwork.networkingPeer.State is still ClientState.Disconnecting, so I can't connect again!

trying to connect with this code:
PhotonNetwork.offlineMode = false;
PhotonNetwork.ConnectToRegion(CloudRegionCode.eu, "2.0");
does nothing and later I get errors when I try to join the lobby. Also PhotonNetwork.insideLobby is true!

If I use this code:
PhotonNetwork.Reconnect();
Then I get this error: Connect() failed. Can't connect while disconnecting (still). Current state: Disconnecting

Also it doesn't matter how long I wait, the status never changes from disconnecting to disconnected.
I am using now this workaround:
if(PhotonNetwork.networkingPeer.State == ClientState.Disconnecting)
PhotonNetwork.networkingPeer.StopThread();

PhotonNetwork.ConnectToRegion(CloudRegionCode.eu, "2.0");
Is there a better way to handle this?

Network Culling Handler - Second player cannot see the first player

$
0
0
Hi,

I added the CullArea, configured it, added the handler script to the characters. When the second player joins, he cannot see the first player(master), the first player can see the second player.

if I disable the cullarea gameobject, disable the scripts on the characters, both players see each other fine, so I definately know its the culling causing the issue.

No errors, infos, warnings in console. Both players show the same inside cell & subscribed cell info, I've tried playing with the size of the cullarea and the divisions, made no difference.

Sometimes, if I cancel play on first player/master, then hit play again and enter game, both players can now see each other, (this is random), it might take a few attempts to get that working.

Unity ver = 5.5.0p3
Photon ver = 1.80

Regards

Carme

Can not get my coloring of players with different colors to work

$
0
0
Hi
I'm working on a arena fighter game. I'm very new to PUN. Right now i have a "waitingRoom" where up to 4 players are waiting for the game to start. Then a player joins a room he need to get on of the following colors: Red, Blue, Green, Yellow. The color depends on which color that isn't taken by another player. Right now i use PhotonNetwork.Instantiate, to create a player prefab then OnJoinedRoom(); is called. The "Player" prefab has a script i use to color the color. It works fine until a specific player leaves the room.

So let's say the first player who joins the room gets the color Red, and the 2.player gets the color Blue, and the 3. player gets the color green. If the 3. player leaves the room and rejoins, every thing work just fine. but then the 2. player leaves and rejoins every is fine on the other clients screen. But on the 2. players screen he got the green color.

My methods look like this:




//Called by void Start()
private void setColor()
{
if (PhotonNetwork.isMasterClient)
{
photonView.RPC("rpcColor", PhotonTargets.AllBuffered);
}
}




[PunRPC]
private void rpcColor()
{
GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
bool[] colorsTaken = new bool[4];

foreach (var player in players)
{
if (player.transform.FindChild("Red(Clone)"))
{
colorsTaken[0] = true;
}

if (player.transform.FindChild("Blue(Clone)"))
{
colorsTaken[1] = true;
}

if (player.transform.FindChild("Green(Clone)"))
{
colorsTaken[2] = true;
}

if (player.transform.FindChild("Yellow(Clone)"))
{
colorsTaken[3] = true;
}
}

for (int i = 0; i < colorsTaken.Length; i++)
{
if (!colorsTaken[i])
{
Instantiate(teamColor[i], gameObject.transform, false);
return;
}
}
}

Thanks in advance :)

PUN & SteamVR_LoadLevel

$
0
0
Descriptions:
PhotonNetwork.LoadLevel(int levelNumber)/(string levelName):
 Called by user scripts to load/sync scene in Unity
Used to stop the messaging queue and sync scenes between players
NetworkingPeer.SetLevelInPropsIfSynced(int levelNumber)/(string levelName):
 Called by PhotonNetwork.LoadLevel(...)
Used to set/update the RoomCustomProperty NetworkingPeer.CurrentSceneProperty ("curScn")
"curScn": The string synced between players holding the current scene name
NetworkingPeer.LoadLevelIfSynced():
 Called by both OnJoinedRoom() & ReadoutProperties(...)
Used to sync the scene when joining the room or "curScn" changed (by MasterClient)
Also calls PhotonNetwork.LoadLevel(int levelNumber)/(string levelName) to load the new scene for the other clients

To use SteamVR_LoadLevel update PhotonNetwork.LoadLevel(int levelNumber)/(string levelName) to use the SteamVR_LoadLevel.Begin(int levelNumber)/(string levelName). (in my game I use the "Scripting Define Symbols" "VIVE" to denote this build is for use with the Vive.)
#if VIVE
SteamVR_LoadLevel.Begin(int levelNumber)/(string levelName);
#else
SceneManager.LoadScene(int levelNumber)/(string levelName);
#endif
NOTE SteamVR_LoadLevel.Begin(int levelNumber) does not exist yet, but you can follow these instructions on how to add it: https://steamcommunity.com/app/358720/discussions/0/333656722980764718/

Matchmaking Template

$
0
0
Hi,

does anyone know a good template for PUN to do matchmaking things that are done in almost every game? Steam Integration, Room List, Friends List etc.?

Need an event callback for inactive players?

$
0
0
I need an event be fired when a player become inactive and when he\she rejoin to the room. IPunCallbacks needs a callback like OnPhotonPlayerInactiveChanged!

Bad sync performance in racing multipalyer (teleporting, lags, etc.)

$
0
0
I basically got the SampleScene with the skycar from unity and wanted to add multiplayer into it. Overall this works fine with PUNFree, but either the cars are teleporting all the time or they are wrong positioned when I activate lerp. Further details can be found in the stackoverflow question since I can add images there. gamedev.stackexchange.com/questions/135792/how-to-tweak-multiplayer-sync-performance-with-pun

The syncing need to be as accurate as possible, since this will be a competitive game, so I did not want to use extrapolating, I hope I'm correct with this one.

Restart scene properly

$
0
0
Hi guys,
I'm making a board game, and I use PUN for the multiplayer online game. But I have some weird issues when I restart scenes. For example, when the players both want to replay :
- The master leaves the scene "game", load a scene "transition" in which this is only a loading scene, in order to destroy all GameObjects in the scene "game", then reload the scene "game" like a new game.
- After the this, because of PhotonNetwork.automaticallySyncScene = true; the client do the same thing.

When I restart, in the master everything works fine, but in client, I have many issues : variables correctly initialised, or some nullPointerException (what I don't have when I launch the first time a game)

So I want to know : How to clear RPC an remove everything in a scene, and when I reload a scene to have my scene knew as if it's the first time I load it.

^^Sorry for my bad English, I'm a french speaker. Thanks for you answer

Animation Trigger not working but all others are.

$
0
0
Hi guys!

So this is probably an easy fix, and im just being numb... currently I've set up the most base framework for my game. Im new to networking with PUN and am enjoying it thus far!

My issue is this... I am using the Photon View in cahoots with Photon Animator View to sync Mechanim animation over network. I can get them all to work fine except for TRIGGERS. The base example im having is : Press LEFT MOUSE BUTTON to ATTACK. In my script I set the trigger and all is ok my end. Then when I link up another client the character doesn't carry out the attack animation on the other end.
I changed it to a BOOL to make sure the code was ok, and it works now at BOTH ends. So, I know I can workround this with bools etc but to put my mind to rest.... how the chuffnuts do I get the trigger animation to play over the network??

I have set the PHOTON ANIMATOR VIEW to continous on all parameters for testing, tried it on DISABLED, DISCRETE and CONTINOUS for the trigger, I even stripped the animation events off the timelines incase they were arsing it all up but nothing seems to fix it :'(

Thanks in advance!

Photon Animator View - What about Triggers?

$
0
0
I see there is probably no way to auto pull triggers by default with this script for animation. However since the Trigger section does not have any comments on how it should be handled in this class, I'm hoping to get some idea on what to place within the trigger case. Currently I am using an RPC from the characters controller script but I feel I can better optimize and make the code more efficient by adding it to the SerializeData?

switch (parameter.Type)
{
case ParameterType.Bool:
stream.SendNext(this.m_Animator.GetBool(parameter.Name));
break;
case ParameterType.Float:
stream.SendNext(this.m_Animator.GetFloat(parameter.Name));
break;
case ParameterType.Int:
stream.SendNext(this.m_Animator.GetInteger(parameter.Name));
break;
case ParameterType.Trigger:

break;

I really love this script and I would hate to have to use a RPC for a trigger (anim property) if there is a more efficient way to use serialization within this class I would love it if someone could give me an example using it with a trigger :) !

lobby/team based/round multiplayer?

$
0
0
Hey guys, I am looking to get some insight on the most practical way to do team and round based Multiplayer with a lobby before the match starts, for example, each game needs a certain about of players, and it will start once all the players have joined in the lobby... once all the players join, it starts the game, and creates each team, and then there is X number of rounds based off a timer.
Where would be the best place to start? I am know it's possible but I am curious to hear what the most proper approach would be from some of the experts, like @JohnTube.

Thanks!

Some questions: Custom room and player properties. Sync some info in room. Set Room closed.

$
0
0
Hello! I'm novice in Photon but not novice in Unity.
I have some questions
1.How can I add custom properties to room and get it?
I was trying it:
RoomOptions roomOptions = new RoomOptions();
roomOptions.CustomRoomProperties.Add("test", "simple");
PhotonNetwork.CreateRoom("text okay", roomOptions, null);
Idk works it or no, but problem it's I can't get this key! How I should?

I have a waiting room before starting the game... So there 2 questions:
2. How can I sync some infos. Like a integer, toggle(checkbox).
3. How can I remove lobby from visible after scene loading(GameStarting)

RPC XOR encryption

$
0
0
Hello, recently my game players began to intercept the data and change them. For protection, I added xor encryption. I wanted to see this method in future updates Photon.
Protection was written by students who hack the game for instructions

NetworkingPeer.cs => RPC

//ts: changed RPCs to a one-level hashtable as described in internal.txt
Hashtable rpcEvent = new Hashtable();

int encryptKey = UnityEngine.Random.Range(1,255);
rpcEvent[(byte)6] = (byte)encryptKey;

rpcEvent[(byte)0] = (int)view.viewID ^ encryptKey; // LIMITS NETWORKVIEWS&PLAYERS
if (view.prefix > 0)
{
rpcEvent[(byte)1] = (short)view.prefix ^ (short)encryptKey;
}
rpcEvent[(byte)2] = PhotonNetwork.ServerTimestamp ^ encryptKey;


// send name or shortcut (if available)
int shortcut = 0;
if (rpcShortcuts.TryGetValue(methodName, out shortcut))
{
rpcEvent[(byte)5] = (byte)shortcut ^ (byte)encryptKey; // LIMITS RPC COUNT
}
else
{
string encryptMethodName = "";
for(int i=0;i<methodName.Length;i++){
encryptMethodName += (char)(methodName[i] ^ (char)encryptKey);
}
rpcEvent[(byte)3] = encryptMethodName;
}


NetworkingPeer.cs => ExecuteRpc
        // ts: updated with "flat" event data
int encryptKey = (int)((byte)rpcData[(byte)6]);
int netViewID = (int)rpcData[(byte)0] ^ encryptKey; // LIMITS PHOTONVIEWS&PLAYERS
int otherSidePrefix = 0; // by default, the prefix is 0 (and this is not being sent)
if (rpcData.ContainsKey((byte)1))
{
otherSidePrefix = (short)rpcData[(byte)1] ^ (short)encryptKey;
}


string inMethodName;
if (rpcData.ContainsKey((byte)5))
{
int rpcIndex = (int)rpcData[(byte)5] ^ encryptKey; // LIMITS RPC COUNT
if (rpcIndex > PhotonNetwork.PhotonServerSettings.RpcList.Count - 1)
{
Debug.LogError("Could not find RPC with index: " + rpcIndex + ". Going to ignore! Check PhotonServerSettings.RpcList");
return;
}
else
{
inMethodName = PhotonNetwork.PhotonServerSettings.RpcList[rpcIndex];
}
}
else
{
string encryptMethodName = (string)rpcData[(byte)3];
inMethodName = "";
for(int i=0;i<encryptMethodName.Length;i++){
inMethodName += (char)(encryptMethodName[i] ^ (char)encryptKey);
}
}

Moving the game avatar around

$
0
0
I have a setup where the game avatar is just a camera with the interest area in front of it to look from a top down at the world. I have code that moves the camera in relation to dragging (via mouse) on the screen, this works but of course just moving the transform around does not let the server know where you have moved. So i tried game.avatar.MoveAbsolute and this is not working out at all.

I currently have both moveabsolute happening and transform moving. I dont feel this is the right approach any advice would be great.


public float dragSpeed = 2;
private Vector3 dragOrigin;
private Game game;
private RunBehaviour runBehaviour;

void Start()
{
runBehaviour = GameObject.Find("Scripts").GetComponent<RunBehaviour>();
game = runBehaviour.Game;
}

void Update()
{

if (Input.GetMouseButtonDown(0))
{
dragOrigin = Input.mousePosition;
return;
}

if (!Input.GetMouseButton(0)) return;

Vector3 pos = Camera.main.ScreenToViewportPoint(Input.mousePosition - dragOrigin);

Vector move = new Vector(pos.x * dragSpeed, pos.y * dragSpeed);
Vector3 move3 = new Vector3(pos.x * dragSpeed, 0, pos.y * dragSpeed);

game.Avatar.MoveAbsolute(move, game.Avatar.Rotation);

//Vector3 move = new Vector3(pos.x * dragSpeed, 0, pos.y * dragSpeed);

transform.Translate(move3, Space.World);

How to Sync Movement with my own physics ?

OnPhotonSerializeView not fire in scene photonView?

$
0
0
Hi, I use photonView on a gameobject which is aready in scene. like this:

In LocalPlayScene.cs :

public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
Debug.Log("OnPhotonSerializeView");
if (stream.isWriting)
{
// We own this player: send the others our data
stream.SendNext(chacters);
}
else
{
// Network player, receive data
this.chacters =(List<SlotContainerKeyPair>)stream.ReceiveNext();
Debug.Log(stream.ReceiveNext());

}
}


But when I play. there's no Log info out.


Am I wrong?
Please Help

Creating room w/o Joining for Integration Testing Purposes

$
0
0
I understand that when you create a room, you are automatically joined to it. However, I was wondering if there was a way to create an empty room programmatically with set of properties so I can write automated tests for some of the SQL joining we plan to support.

I'm using Unity Test Tools integration tests and have things going well aside from the above. Here is the exact scenario I would like to accomplish:

Connect to photon

Create a room with custom properties

JoinRandomRoom with SQL that does not satisfy based off the room just created

JoinRandomRoom with SQL that succeeds based off the room just created

The only thing that comes to mind is running an instance of the build which creates the room and my tests execute the join failure/success assertions. However, this is less than ideal.

Thanks for the assistance.

Best, Adam

PUN connection error

$
0
0
Hi I am new to PUN and here. Sorry if the post is in wrong topic but,
I created a game with pun. I can connect to server when i run game in unity but when i run the game after i build it does not connect.

Sort playerlist

$
0
0
Anyway to sort playerlist. I wana sort players with their kills key. Anyway to achieve this
Viewing all 8947 articles
Browse latest View live


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