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

IPunPrefabPool Working Sample with SmartPool(free)

$
0
0
Hi Everyone, I created a working sample of IPunPrefabPool for effectivly use a pooling system for your network object instances. works from Unity 4.7 and Unity 5. It's available on github: https://github.com/jeanfabre/Exitgames--PUN--Pooling_u4 You can download it directly here if you don't want to clone the rep. It's very simple, straight to the point and the main script you are interested in really is this one: PunSmartPoolBridge.cs It's using a free pooling system called SmartPool but really, once you understand the basics, you can switch to any pooling system. Watch out for the few things to know: - You need to keep your prefab inside a Resources folder anyway, It's important for PUN to load that prefab and analyze photonViews to assign viewIds. Note that there are no instantiation, it's only loaded - On the Prefab instance, use OnPhotonInstantiate() to catch initialization, Start() and OnEnabled() are not suitable for reliable data across the various cases of instantiation and pool usage accross the network. Let me know if you have questions :) Bye, Jean

Photon Unity Networking (PUN) problem

$
0
0
Hello how can i solve this problem. It happened when I tried to build my game. "Copying assembly from 'Temp/PhotonChat.dll' to 'Library/ScriptAssemblies/PhotonChat.dll' failed"

[PUN CLASSIC] Sharing Hololens World Anchor with Photon

$
0
0
Hello, I'm trying to share a Hololens World Anchor with PUN CLASSIC. It is composed of an array of bytes of several Mbs and I seem to be unable to pass it with RPCs. Since I read that the Photon Cloud doesn't allow arguments of RPCs to be more than 0.5Mb in size I'm hosting my server with the provided Load Balancing application. What I did was initially to try to share each chunk (array of bytes roughly 2Mbs in size) with an RPC but I ended up disconnected from the server. Then I tried to split the chunks even more to pass an array of 1150 bytes with each RPC but I end up getting disconnected from the server again after (successfully) sending the last part. These are my errors: Receiving failed. SocketException: TimedOut OnStatusChanged: ExceptionOnReceive current State: Joined SocketTcp.Disconnect() OnStatusChanged: TimeoutDisconnect current State: Disconnecting Can't execute Disconnect() while not connected. Nothing changed. State: Disconnecting SocketTcp.Disconnect() OnStatusChanged: Disconnect current State: Disconnecting I am using TCP in the PhotonSettings. If anyone could help me, I would be very grateful :D Thank you in advance.

Can't reconnect after Timeout: ReconnectAndRejoin() failed.

$
0
0
I am developing a multi-user VR experience. We are using PUN v2 in Unity and a Photon OnPremise server instance. For some reason we get very frequent timeouts and I can't find a way to reconnect and rejoin the room after a disconnection. If I use the PhotonNetwork.ReconnectAndRejoin() method I get this error: ReconnectAndRejoin() failed. It seems the client doesn't have any previous authentication token to re-connect. If I try to connect normally, I am told that the Client is already connecting, or that the player is already in the room, or that the room is full, depending on the order of the callbacks. As a sidenote, NetworkClientState always seems to return ConnectingToGameServer. Any pointer as to what could be going wrong would be very appreciated. Code snippet below:
public override void OnConnectedToMaster()
{
	Debug.Log("Joined Master...");

	PhotonNetwork.JoinLobby();
}

public override void OnJoinedLobby()
{
	Debug.Log("Joined Lobby...");

	RoomOptions options = new RoomOptions();
	options.EmptyRoomTtl = 30000;
	options.PlayerTtl    = 120000;
	options.MaxPlayers   = 2;

	PhotonNetwork.JoinOrCreateRoom("Default", options, TypedLobby.Default);
}


public override void OnJoinedRoom()
{
	if (playerPrefab != null)
		PhotonNetwork.Instantiate(playerPrefab.name, Vector3.zero, Quaternion.identity, 0);

	NetworkingSpawner spawner = FindObjectOfType();
	if (spawner != null)
		spawner.OnNetworkingStarted();
}

public override void OnDisconnected(DisconnectCause cause)
{
	Debug.LogWarning("Disconnect.." + cause);
	if (cause == DisconnectCause.ClientTimeout)
		PhotonNetwork.ReconnectAndRejoin();
}

....

void Connect()
{
	Debug.Log("Try connect...");
	if (!PhotonNetwork.IsConnected)
	{
		PhotonNetwork.ConnectUsingSettings();
	}
}

PUN+ PHP API

$
0
0
I'm not able to find anything on this, but our players are able to join other players via our website at worldtobuild.com. We'd like to be able to get information from photon about rooms and lobbies from our php server. Are there any solutions that make this possible? We've thought of having an instance of Unity run on the server simply to grab the information and relay it to our server, but that seems a bit complex for just retrieving a bit of information. Are their any web API available for PUN+?

fake lag

$
0
0
Is there a recommended way to fake lag or latency using PUN? My ping is 50ms when testing here, I'd like to see 150-200ms.

RPC request issue

$
0
0
Hi, I've got this : called in the same class there: and it return me that error:

Join to room with save proggress

$
0
0
How can you do that the player is running around the scene - map_1 , and at the same time searching for the room with the same scene - map_1 with other players. And when he finds it, he joins it with his progress saved For the player, other players just suddenly appear.

Instantiated object's view id is 0

$
0
0
I have a object pooling system for bullets and bullets have photon view component. But when game starts all bullet's view id is 0. That makes no sense to me, any ides why?

Failed parsing address

$
0
0
When I try and connect to a server, (this is only a test project, and I am making the lobby) I get this error; Failed parsing address. The full error is: Failed parsing address: UnityEngine.Debug:LogError(Object) Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2057) ExitGames.Client.Photon.IPhotonSocket:Connect() ExitGames.Client.Photon.SocketUdp:Connect() ExitGames.Client.Photon.EnetPeer:Connect(String, String, Object) ExitGames.Client.Photon.PhotonPeer:Connect(String, String, Object) Photon.Realtime.LoadBalancingClient:Connect() (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:724) Photon.Pun.PhotonNetwork:ConnectToMaster(String, Int32, String) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:1184) Photon.Pun.PhotonNetwork:ConnectUsingSettings() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:1116) Com.MyCompany.MyGame.Launcher:Connect() (at Assets/Launcher.cs:43) UnityEngine.EventSystems.EventSystem:Update() My script looks like this, right now: using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Realtime; using Photon.Pun; namespace Com.MyCompany.MyGame { public class Launcher : MonoBehaviourPunCallbacks { string gameVersion = "1"; [SerializeField] private byte maxPlayersPerRoom = 4; [SerializeField] private GameObject controlPanel; [SerializeField] private GameObject progressLabel; void Awake() { PhotonNetwork.AutomaticallySyncScene = true; } void Start() { progressLabel.SetActive(false); controlPanel.SetActive(true); } void Update() { } public void Connect() { progressLabel.SetActive(true); controlPanel.SetActive(false); if (PhotonNetwork.IsConnected) { PhotonNetwork.JoinRandomRoom(); } else { PhotonNetwork.GameVersion = gameVersion; PhotonNetwork.ConnectUsingSettings(); } } //public void OnDisconnectedFromServer() //{ // progressLabel.SetActive(false); // controlPanel.SetActive(true); //} public override void OnConnectedToMaster() { Debug.Log("PUN Basics Tutorial/Launcher: OnConnectedToMaster() was called by PUN"); } public override void OnDisconnected(DisconnectCause cause) { progressLabel.SetActive(false); controlPanel.SetActive(true); Debug.LogWarningFormat("PUN Basics Tutorial/Launcher: OnDisconnected() was called by PUN with reason {0}", cause); } public override void OnJoinRandomFailed(short returnCode, string message) { Debug.Log("PUN Basics Tutorial/Launcher:OnJoinRandomFailed() was called by PUN. No random room available, so we create one.\nCalling: PhotonNetwork.CreateRoom"); PhotonNetwork.CreateRoom(null, new RoomOptions()); } public override void OnJoinedRoom() { Debug.Log("PUN Basics Tutorial/Launcher: OnJoinedRoom() called by PUN. Now this client is in a room."); } } } Please help if you can! I really need to fix this error!

Failed parsing address:

$
0
0
I was able to use photon local server before. After updated photon asset to v2.14, I cant connect to my local server. errors below.
Failed parsing address: UnityEngine.Debug:LogError(Object) Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String) (at Assets/Libs/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2057) ExitGames.Client.Photon.IPhotonSocket:Connect() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/IPhotonSocket.cs:104) ExitGames.Client.Photon.SocketUdp:Connect() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/SocketUdp.cs:63) ExitGames.Client.Photon.EnetPeer:Connect(String, String, Object) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:273) ExitGames.Client.Photon.PhotonPeer:Connect(String, String, Object) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1242) Photon.Realtime.LoadBalancingClient:ConnectToGameServer() (at Assets/Libs/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:854) Photon.Realtime.LoadBalancingClient:OnStatusChanged(StatusCode) (at Assets/Libs/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2536) ExitGames.Client.Photon.<>c__DisplayClass105_0:b__0() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PeerBase.cs:907) ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:435) ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1548) Photon.Pun.PhotonHandler:Dispatch() (at Assets/Libs/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:193) Photon.Pun.PhotonHandler:FixedUpdate() (at Assets/Libs/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:127)

RPC

$
0
0
My player is changing armor mesh when he equips item from inventory, so for each armor part he has a different mesh, now when im in the room with other players and changing my armor they don't see that im changing meshes. They are still seeing a naked player. Im using Photon Pun and i'm wondering which method would be the best to use here. Should i set RPC on method where i instantiate mesh and send that rpc to everyone, or is something else better? Im usually using rpc for methods like "takedamage" and simillar, would it work the same in my case?

Network Usage with PhotonViewTransform

$
0
0
I tested 1 gameobject to network syncing with photon view transform (using photon view) and then I found it costs 16kbps in sending and receiving. (I checked Reliable Delta Compressed in PhotonView) but my game is going to be 100 vs 100 in network syncing and I am worried about using too much network usage. and today I found "Simple Network Sync" https://assetstore.unity.com/packages/tools/network/simple-network-sync-134256 they said they are "EXTREMELY low network usage compared to the UNET/PUN transform sync components, with a range of compression and culling options." so here is my question 1. Is it true that PUN2 with "Simple Network Sync" is "EXTREMELY low network usage" than PUN2 only? 2. Is there any other way to decrease network usage?

What happens when JoinOrCreate is called an the desired room is full?

$
0
0
Hello there, what happens when I let the user call the JoinOrCreate room method and the desired room to enter is full like 8/8. Actually i want to open the next room with the same name +1 (room1, room2 etc.). Does it happen automatically? Greets

Photon Animator Issue

$
0
0
Hello, I'm using photon unity network 2. I have use photon animator view. When I call trigger from master client, it calls trigger perfectly in all the clients. and When I call trigger from clients, it doesn't call. There is one common object in all the clients. Can you please guide me what would be the problem? TIA

Set timeout for trying to connect to photon server

$
0
0
hi, I use PUN 2.12 and I want to reduce timeout for trying to connect to photon server for showing retry message to the user in UI but I can't find PhotonNetwork.networkingPeer.DisconnectTimeout in PUN SDK. any suggestions?

Photon Master cannot be connected randomly.

$
0
0
Hi @JohnTube The errors are as follows: SocketTcpAsync.EndReceive SocketException. State: Connected. Server: 'master_ip_address' ErrorCode: 10054 SocketErrorCode: Connect 112 at System.Net.Sockets.Socket.EndReceive (System.IAsyncResult asyncResult) [0x00012] in <3845a180c26b4889bc2d47593a665814>:0 113 at ExitGames.Client.Photon.SocketTcpAsync.ReceiveAsync (System.IAsyncResult ar) [0x00023] in <e2387f9dc4784e52ba991612d3ef9d 114 v Please help or give me some tips ,thanks very much.

The game has been frozen for 10-15 seconds after resume

$
0
0
I have a problem that after the client sees the ad for about 30 seconds and returns to the game. I had the problem of missed events being sent sequentially to the client and often the game froze for 10-15 seconds. How to resume the photon can receive the fastest events and does not freeze the game. Please help me.

PhotonStream.currentItem overflows with no warning

$
0
0
This has come up before I see, but I've just been bitten by this. If you send more than 253 items in a view then currentItem overflows on the reading end and you get bad data from ReceiveNext. Could an exception be thrown on write or read end to prevent this confusion? Took me a few hours to figure out (although I learned a bit so not a total loss :) )

Syncing list of players who start the game

$
0
0
When our game is finished loading a level, each client writes a player property to indicate they are ready to play. After this, all the clients periodically check the PhotonNetwork.playerList to see that all players have this property written. The clients then store information for each player who is beginning the level. It is important that all clients store the same information for the players. My question is, due to a player disconnecting would it be possible for two clients to see a different list of players? I don't see how this would be possible, but I want to check to be sure.
Viewing all 8947 articles
Browse latest View live


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