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

SteamVR Interactable Object Problem on Photon

$
0
0
Hi everybody, I'm trying to integrate Photon with SteamVR. I created avatars with PhotonNetwork.Instantiate and also I created Interactable Objects in hierarchy but not instantiate with PhotonNetwork.Instantiate. Interactable object is one of the throwable cubes in SteamVR's Interaction Example Scene. My Camera Rig is "Player" from that scene. But when I interact with the object, the other client cannot see the object while I'm holding it. It has PhotonView, PhotonTransformView. and i was also try by adding PhotonRigidbodyView and make rigidbody isKinematic is true. but i am having same issue, pickup of object in hand is not showing to other players. Thanks in advance.

Pun2 CustomProperties coming null

$
0
0
Im getting the NullReferenceException error telling me im not setting somewhere and I'm having alot of trouble figuring it out.. so as the player joins the room i set properties for the local player with cached values from PlayFab(User Statistics) and im trying to share these values in a room. Once the room is full(two players) im setting a local variable like this, RemotePlayer = PhotonNetwork.LocalPlayer.GetNext(); , then taking that RemotePlayer and passing it into this function. public void SetEnemyInfo(Player _player) { Player player = _player; _enemyPlayerName.text = (string)player.CustomProperties["PlayerName"]; _enemyPlayerWins.text = "" + (int)player.CustomProperties["Wins"]; _enemyPlayerRating.text = "" + (int)player.CustomProperties["Rating"]; } when the room is full this is called private void SetOtherPlayer() { EnemyListing.Instance.SetEnemyInfo(RemotePlayer); } My error is occuring on the "Wins" line however the player name doesn't post either. Im doing this method the exact same for the local player only using the LocalPlayer built in variable(works fine). The SetEnemyInfo method even works for the second player joining but not the first player in the lobby. I may be trying to make this way more complicated than this needs to be but if I could receive some guidance I'd be grateful

Destroy empty rooms

$
0
0
Hello, When two players will finish game and exit application, room still exist with 0 players. How to destroy this room from master serwer?

PUN never calls back on connect

$
0
0
All I've done is install PUN v2 (Free) for the first time, and make an incredibly simple 'test' project, and no matter what I try Photon never gets past the 'pinging servers' stage. I've been scouring the specifications and setup pages but none of them contain any new information that I can use. When I check my app logs in Photon's web interface, it shows brief activity but none of my 20 CCU has been used. Using Unity 2018.3.0f2 on Windows 10. Unity has open Firewall access. Downloaded Photon PUN v2 (Free) today. I created an empty GameObject to manage the networking, and a C# script I added my app ID, turned logging to Full, game version to "1", and left all other defaults. The script. ------------------------------------------------------------------
void Start()
    {
        if (Photon.Pun.PhotonNetwork.IsConnected)
        {
            Debug.Log("$$$");
        }

        Debug.Log("J");
        Photon.Pun.PhotonNetwork.GameVersion = gameVersion;
        bool connect = Photon.Pun.PhotonNetwork.ConnectUsingSettings();
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    private void OnConnectedToMaster()
    {
        Debug.Log("AAAAAAA1");
    }
    private void OnJoinedLobby()
    {
        Debug.Log("AAAAAAA2");
    }
    private void OnConnectedToPhoton()
    {
        Debug.Log("AAAAAAA3");
    }
    private void OnDisconnectedToPhoton()
    {
        Debug.Log("AAAAAAA4");
    }
    private void OnFailedToConnectToPhoton()
    {
        Debug.Log("AAAAAAA5");
    }
    void OnJoinedRoom()
    {
        Debug.Log("AAAAAAA6");
... ------------------------------------------------------------------ Debug.Log "J" is the only message I get other than ... "PUN got region list. Going to ping minimum regions..." and then a series of regions 'eu' and so on. All have 'available but was not pinged', except for one, which had a 26ms ping. The program does nothing else. It does not crash. All other functions (as minimal as they are) continue. Again, this is basically a default project with a default install... and I've found nothing on what to do to even get better information. What can I do to get better logs client side? What can I do to get a callback on the connection? None of the above callbacks are ever called.

Do different version of Photon 1 interact? How to upgrade?

$
0
0
We have a nearly finished game built around Photon 1.91. I am building a separate game that should be able to join the above game on Photon. The two Unity applications cannot see each other's rooms, though they can see their own. I have verified the two games use the same App-Id and are pointed to the same region on Photon Cloud, both using Udp. We are using the same string for ConnectUsingSettings() on each "0.0.0" and I am using the same command for joining a lobby on each, PhotonNetwork.JoinLobby(TypedLobby.Default); The only difference I can see between the two is the original application was built in 1.9.1. The new app is 1.9.6. Do different version of Photon 1 talk to each other? Should I make the applications match Photon revisions?

Cannot update Photon Unity Networking package

$
0
0
I have currently installed the version v1.91 (6. July 2018) I normally on update it thorugh the asset store, I locate the package and select update. But looks like now it only says import.

Can't Reconnect when Disconnected via ServerTimeout

$
0
0
PUN 2.10, Photon Cloud, Region us I'm trying to silently reconnect users when they are disconnected, whether in a lobby, or in a room. In my current test, I have a Host device, and a Guest device.. The Host creates and joins the room. The guest joins the room. I pause the guest's unity editor until the guest drops from the Host's room, then I unpause the unity editor. No matter what I call from the guest machine, ConnectUsingSettings(), Reconnect, or RecconnectAndJoin(),, or RejoinRoom, nothing is working. The sequence of events after I unpause is as follows: OnDisconnect is fired with ServerTimeout (Disconnected GameServer) OnLeaveRoom then fires (Disconnected GameServer) Then my Network Objects are destroyed (2 players), one after the other Generally, when I call something, it will immediately fire OnDisconnected with cause of None Then I usually get the following error: Operation Authenticate (230) not called because client is not connected or not ready yet, client state: Disconnected Is there a chart that can tell me what to call based on what state and disconnect cause? Seems like this shouldn't be this difficult, or a reconnect recovery tool (small class should already be available for this, which is what I'm trying to write). Thanks in advance.

How to change room name?

$
0
0
Hello, in my game, rooms are created with name as admin nickname. But if admin will left and somebody else become admin, room should change name to his nickname without kicking out all players. How can I change room name?

Best way to step through in VS with Photon?

$
0
0
The most frustrating part of debugging is when I have to go through several Rpc's where I get disconnected and my breakpoints decide to just step out randomly (I'd have to restart again) due to disconnection. How can I better debug (stepping through) without d/c and VS going crazy? I'm just debugging solo, so I don't care if external rpcs fail, I just want my local one to work (since everyone target just triggers locally anyway).

Sync SteamVr Finger Position with photon

$
0
0
Hey, I have been struggling lately with syncing the finger positions with SteamVr. Everyone just sees their own hands on everyone else.
I don't know how to even start tackling this problem. (There is no place to add Photon.isMine).
Thanks!

Help with RPC for Line Renderer

$
0
0
Hi everybody, i'm trying to make other players see my line renderer, in order to create a graffiti shared experience in augmented reality. But my script is not working, could you please take a look ? i would appreciate. using UnityEngine; using System.Collections; using System.Collections.Generic; [RequireComponent( typeof(LineRenderer) )] public class CurvedLineRenderer : Photon.MonoBehaviour { //PUBLIC public GameObject PaintingManager; public Dictionary mLines = new Dictionary(); public float lineSegmentSize = 0.15f; public float lineWidth = 0.1f; [Header("Gizmos")] public bool showGizmos = true; public float gizmoSize = 0.1f; public Color gizmoColor = new Color(1,0,0,0.5f); //PRIVATE private GameObject Painting; private CurvedLinePoint[] linePoints = new CurvedLinePoint[0]; private Vector3[] linePositions = new Vector3[0]; private Vector3[] linePositionsOld = new Vector3[0]; // Update is called once per frame public void Update () { GetPoints(); SetPointsToLine(); CreateLine(); } void GetPoints() { //find curved points in children linePoints = this.GetComponentsInChildren(); //add positions linePositions = new Vector3[linePoints.Length]; for( int i = 0; i < linePoints.Length; i++ ) { linePositions[i] = linePoints[i].transform.position; } } void SetPointsToLine() { //create old positions if they dont match if( linePositionsOld.Length != linePositions.Length ) { linePositionsOld = new Vector3[linePositions.Length]; } //check if line points have moved bool moved = false; for( int i = 0; i < linePositions.Length; i++ ) { //compare if( linePositions[i] != linePositionsOld[i] ) { moved = true; } } //update if moved if( moved == true ) { LineRenderer line = this.GetComponent(); //get smoothed values Vector3[] smoothedPoints = LineSmoother.SmoothLine( linePositions, lineSegmentSize ); //set line settings line.positionCount = smoothedPoints.Length; line.SetPositions( smoothedPoints ); line.startWidth = lineWidth; line.endWidth = lineWidth; } } void OnDrawGizmosSelected() { Update(); } void OnDrawGizmos() { if( linePoints.Length == 0 ) { GetPoints(); } //settings for gizmos foreach( CurvedLinePoint linePoint in linePoints ) { linePoint.showGizmo = showGizmos; linePoint.gizmoSize = gizmoSize; linePoint.gizmoColor = gizmoColor; } } void CreateLine() { if (photonView.isMine) { Vector3[] positions = new Vector3[Painting.GetComponent().positionCount]; SendLine(positions); } [PunRPC] public void SendLine(Vector3[] positions) { Painting.GetComponent().GetPositions(positions); mLines.Add(Painting, positions); PhotonView photonView = PhotonView.Get(this); if (photonView.isMine) photonView.RPC("SendLine", PhotonTargets.OthersBuffered, positions); } }

Unreliable messages dropped

$
0
0
I am synchronizing transforms using Photon Views set to "Unreliable on change". This works great up until a certain point of about 30 or so actively moving transforms, at which point some of my transforms stop synchronizing. In my case I only have two peers. I have tried lowering the send rate and serialization rate as low as 1 but this still happens. It seems like two peers with a sendrate of 1 should work without much issue. This actually wouldn't be a big deal, except that the messages being dropped always seem to happen to the same transforms, creating a big discrepancy between clients for those transforms. I know that there is no guarantee that unreliable messages are going to be received, but are there any settings I can adjust to tweak to adjust the amount of unreliable messages being dropped? From my searching, it looks like there used to be a "PhotonPeer.LimitOfUnreliableCommands" but that was removed. Is there still such a limit? Would it be better for my use case to switch to reliable delta compressed?

IS there an example of CAS anywhere?

$
0
0
I tried this over on the Unity forums with no luck. Does anyone have a code example for changing a RoomProperty in Photon using CAS, that includes the error handling? I have a float[] as a custom property. The various players can change elements of the float array. However, because of concurrency, while I try to change one element, another player may try to change a different element. Ultimately what I am looking for (psuedocode) ChangeRoomProperties() { ReadRoomProperties() //casting them to an array[] alter the desired element recreate Hashtable room.SetCustomProperties(prop, oldvalueProp); if error == incorrect oldValueProp { ChangeRoomProperties() } }

Delete

$
0
0
Admin can delete please (: figured it out

How to update Unity project from PUN v1 to v2

$
0
0
I'd like to update my current Unity project from PUN to PUN 2. I've tried "updating" PUN from the asset store but that didn't seem to do anything. I then tried just downloading PUN 2 in the asset store and then I got a bunch of errors from PhotonRealtime about how certain type or namespaces couldn't be found. My base problem is that I'm trying to access PhotonNetwork.LocalPlayer (which doesn't seem to be apart of the original PUN?) and after downloading PUN 2, I still can't access it. Is this something I need to change in my Applications on my online Photon account? Any advice is appreciated. Thanks!

Camera Per Player

$
0
0
How can I make it so there is a camera per player? I know how to make it for a third person game but I am making a first-person game and don't know how to make it work. The difficult part for me is that there are two cameras attached to the player prefab. One for holding the items and one for simply seeing everything else. I am guessing to make it work, you need to already have the cameras on the scene. I don't know how to position them correctly and making the player rotate with the camera. I'm also using PlayMaker. (I have the cameras working perfectly on the player prefab itself. Although to make it work with multiplayer, I am assuming that you need the cameras already on the scene, which I only know how to make that work with a third person game.)

PhotonTargets.AllBufferedViaServer not for old master switch

$
0
0
Hi, I am trying to buffer RPC's so all new people into the room get them. Master creates a "race" with a number of variables sent to other players via RPC. 1. Master raises the RPC's using AllBufferedViaServer ... ok 2. others joining room receive RPC's ... ok 3. someone remains in the room 4. Master then leaves the room, master switches correctly, 5. if the old master rejoins the room, they don't get the original RPC's. ... why? Anyone can help me, tks.

Master Client - Am I using it incorrectly?

$
0
0
Hi, thanks in advance for anyone that can help me. Quick rundown of my game: - 2 player MAX head-to-head - Players take turns - like Golf Clash (player 1 shoots, then the opponent shoots, then back to player 1) So I'm using the Master Client as the "controller" of the game. The Master Client decides things like a a list of random numbers to use for the whole game (including the seed), the wind, the hole to use, the flag position, etc. From hole to hole, the Master Client makes these decisions, and sometimes makes decisions during a hole (is the game taking too long and send a warning? Should a squirrel come out and steal the ball? etc). Everything works great, but now I am starting to work on disconnects/rejoins. Here's the problem: the Master controls the STATE basically because the Master has control over the random numbers and other info that was never sent to the other player because they don't need to know everything, just the info sent to them. When there is a disconnect, the Master can switch hands, correct? Does that mean everything that the master "controls" needs to be sent to the other player? But if the Master was disconnected, they can't send the info because they are disconnected. According to the docs: "Photon Server detects when a Master Client disconnects and assigns another actor in the room as the new Master Client. By default, the active actor with the lowest actor number is chosen." Do I need to check to see if the opponent became the Master, then give control back to the Master when they come back? I've read the pertinent documentation, and I think I get it, but is there a best practices to something like this? Am I using the Master Client incorrectly?

Am I supposed to keep checking PhotonView objects != null

$
0
0
When an object is instantiated by Photon and "photonView.isMine" is false, I keep a reference to it and use it to keep track of them in-game. MainGame mainGameObject; Awake() { if(photonView.isMine) { mainGameObject.opponent = this; } } Update() { if(mainGameObject.opponent != null) // is this correct? { // point camera at opponent, get vector to opponent, etc. } } I think this is a simple question. Am I supposed to check for any references of objects that have a PhotonView attached for != null before acting on them? I have them sprinkled all throughout the code, so I just want to make sure I'm doing things the "Photon" way. (Sorry about the formatting, code tags didn't seem to work well) Thanks!

Help with displaying player names in lobby room

$
0
0
Hi! I'm having a problem with my code, i was trying to follow this tutorial. The code for displaying the players names in the rooms doesn't work, here is the code, foreach (Player player in PhotonNetwork.PlayerList) //loop through each player and create a player listing { GameObject tempListing = Instantiate(playerListingPrefab, playersContainer); Text tempText = tempListing.transform.GetChild(0).GetComponent(); tempText.text = PhotonNetwork.NickName; } and the error is " Assets/Scripts/Photon/CustomMatchmakingRoomController.cs(40,49): error CS0030: Cannot convert type `Photon.Realtime.Player' to `Player' " (Talking about this line of code 'foreach (Player player in PhotonNetwork.PlayerList)') Any help would be greatly appreciated, Thanks! :smile:
Viewing all 8947 articles
Browse latest View live


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