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

App crashes when closed, Editor crashes when running more than once

$
0
0
Hi, I seem to have a weird problem with PUN2 2.17.1 and Unity 2019.3.9.
I am trying my game out on one computer, creating a room in the editor play-mode and joining in the standalone build. So far that works. The problem occurs when I close the game. When I close the standalone build it simply crashes. When I stop the editor play-mode from running at first it seems fine but when I try to run it a second time the editor crashes.
I thought it would be because I don't disconnect properly but I also tried it with manually disconnecting and only closing the application after I get the callback that it disconnected. Still getting the same problem.
Would be grateful for any help!

[PUN2] Ownership Callback Documentation - mistakes/lack of clarity?

$
0
0
I've just started using PUN2 for a multiplayer adventure game, which is going to involve a lot of transferring and enforcing ownership of objects. Unfortunately, it seems the documentation at https://doc-api.photonengine.com/en/pun/v2/interface_photon_1_1_pun_1_1_i_pun_ownership_callbacks.html is somewhat lacking (if I had to guess, I'd say it had been copy-pasted from PUN classic?)

A few questions that arise from looking at this page:

"This interface is used as definition of all callback methods of PUN, except OnPhotonSerializeView." -> seems to be badly-named then, I would have expected the IPunOwnershipCallbacks interface to define only those callbacks related to Ownership? (Although, it seems you don't actually need to explicitly reference this interface anyway - you can just include the desired callbacks by name in any script)

"Preferably, implement them individually" -> I'm not sure what that means? How can you implement a callback method any way other than individually? Do you mean that you should only have one script - i.e. a centralised Network Object Manager object - that implements these methods within a project? (that seemed to be the advice given in Pun v1, here: https://doc.photonengine.com/en-us/pun/v1/demos-and-tutorials/package-demos/ownership-transfer)

"MonoMehaviour" -> Typo of MonoBehaviour

"PUN will call these methods on any script that implements them", but then, further down the page "OnOwnershipRequest is Called when another player requests ownership of a PhotonView from you (the current owner). " - so is OnOwnershipRequest called on *every* object, or only on the one that contains the photonView being requested for transferral?

In the description of both OnOwnershipRequest() and OnOwnershipTransfered() it states "The parameter viewAndPlayer contains: PhotonView view = viewAndPlayer[0] as PhotonView;", but there isn't a parameter called viewAndPlayer - there are two parameters called targetView and requestingPlayer.

Any clarification on exactly the conditions, and on which clients, these two methods are called would be gratefully appreciated!


RigidBody networked player is jittering using PUN

$
0
0
Hello there,

Very new to Pun, but I spend Wednesday working on getting a networked version of my game running and although I finally got something running, the results I'm getting aren't quite there.

The problem I've got is that remote players look like they are jittering around... from their point of view they are flying smoothly and I look like I'm jittering.

My game is an FPV quad sim, usually, the quad would fly very smoothly. I attempted to capture a video of this and my best attempt was here image If you look when we cross above the building there's a lot of jitter happening.

I feel like I must be missing something, but I'm not sure what, I worked through the tutorial code and then cracked on with mine - there were quite a few changes to make (and still some to do) but I believe I have the important aspect done - like the fact that each quad is now a prefab and so can be instantiated over the network. Each quad also has a rigidbody component which is not kinematic and does use gravity. Also in the prefab is a Photon View, Photon Transform View (sync is on for Position and rotation) and Photon Rigidbody view with sync on for velocity and angular velocity. The observed components in the Photo View are set to the PhotonRigidBodyView and PhotonTransformView.

Within the controller script - essentially which processes the input from the player and turns it into direction and velocity I have enclosed the vast majority of the code inside if (photonView.IsMine) {} ... although it was fun finding out why, and what happens when you don't turn the cameras off on the quads that aren't yours :smile:

If kind of feels like the position is having a fight between the local script and syncing with the client, but with the client the only one giving input, the only thing that the local version of the quad is doing is really adding gravity and drag to an object... which should be the same on both ends.

Is my approach here correct? I noted there was also PhotonTransformViewClassic available as an alternative, although classic sounded like an older version. What should I be using to have these rigidbody player models sync'd smoothly together ?

Trying to Instantiate a array

$
0
0
Hey, i am currently trying to get the following code working, its a array.
gameObj = PhotonNetwork.Instantiate(availableObjects[i], gameObject.transform.position, Quaternion.identity, 0);

Heres the error: No appropriate version of 'PhotonNetwork.Instantiate' for the argument list '(UnityEngine.GameObject, UnityEngine.Vector3, UnityEngine.Quaternion, int)' was found.

Thanks for your help in advance.

Custom Player Properties only working for first person in room?

$
0
0
Hi, I'm trying to load in player weapons using Custom Player Properties, and for some reason they're only working for the first person in the room, or sometimes not at all. The script that sets these isn't disabled for other clients, but does an isMine check before setting them. I'm not sure what's going wrong here. Here's my code:
public void SetupWeapons()
    {
        if(view.isMine)
        {
            //Basically cramming everything into one string.
            //Should look like BODY:(body)|BARREL:(barrel)|OB:(overbarrel)|UB:(underbarrel)

            string WeaponString = "BODY:" + WeaponManager.instance.ourWeapon.body + "|" + "BARREL:" + WeaponManager.instance.ourWeapon.barrel;
            if (WeaponManager.instance.ourWeapon.overBarrel != null)
            {
                WeaponString += "|OB:" + WeaponManager.instance.ourWeapon.overBarrel;
            }
            if (WeaponManager.instance.ourWeapon.underBarrel != null)
            {
                WeaponString += "|UB:" + WeaponManager.instance.ourWeapon.underBarrel;
            }
            ExitGames.Client.Photon.Hashtable props = new ExitGames.Client.Photon.Hashtable();
            props.Add("Weapon 1", WeaponString);
            PhotonNetwork.player.SetCustomProperties(props);
        }

        LoadWeapon((string)view.owner.CustomProperties["Weapon 1"]);
    }

Cannot join other room (using PUN2 with Photon Server's Load Balancing)

$
0
0
Hello, I have a problem when trying to join a created room,

I can connect to the master server, I did it by following codes:
```
PhotonNetwork.NetworkingClient.SerializationProtocol = ExitGames.Client.Photon.SerializationProtocol.GpBinaryV16;
PhotonNetwork.AutomaticallySyncScene = false;
PhotonNetwork.OfflineMode = false;
PhotonNetwork.ConnectToMaster(masterAddress, masterPort, "Master");
```

Then join lobby when connected to master
```
public override void OnConnectedToMaster()
{
base.OnConnectedToMaster();
Debug.Log("Connected to master");
PhotonNetwork.JoinLobby();
}
```

Then after joined lobby, create room by following codes:
```
PhotonNetwork.CreateRoom("RoomName");
```

The "Client A" which created the room can join the created room.

But when I try to join room with "Client B" by following codes:
```
PhotonNetwork.JoinRoom("RoomName");
```

It can't connect, load balancer client state changed to connected to master.

OnJoinedRoom callback won't be triggered, don't know why.

Player.JoinTeam("SomeTeam") doesn't update the players team

$
0
0
Hello everyone,
I have been asking much recently and that's not actually my style. I am actually an independent developer, but sometimes the networking stuff and it's errors are pretty confusing.
Now my problem is:
I am setting the team of every player in the room in Start() actually (in a method which is called in Start()). And exactly 3 seconds later, I try to get the team of the local player, but it gives me an error. And then I checked if the Team == null and it really is. But why? Does Player.JoinTeam() not update the team of the player immediately?

Does Player.JoinTeam("SomeTeam") even synchronize over Network if it's just called by the master client or is it just called locally which doesn't make sense. But I can't find another explanation.

Thank you already in advance

PUN2 won't update to other client while inactive?

$
0
0
How I reproduce it is: start 3 clients, move characters in client 1 and 2 to somewhere then join with client 3, I won't see client 1 and 2 character position are start position (It won't update), I have to active client 1 and 2 to make them updates. Not sure there is any setting to make it always update? (position syncing by `IPunObservable`)

And also callbacks such as OnPlayerEnteredRoom which is the place that I put codes to send some RPC to new players won't be triggered too.

Asset bundle for spawning new object from server

$
0
0
Hi !

We are using PUN2 for one of our multiplayer game and we are trying to load objects using asset bundle. However, running into issues. Can someone pls help. thanks in advance.

thanks

Photon chat

$
0
0
I am working on a chat script using Photon, but the chat does not work for certain languages, such as Arabic, Persian, etc., is there a solution to this problem? I have used all the assets found on the site and I have not found a solution.
Thanks

[PUN2 Bug Report] OnOwnershipTransfered callback getting fired multiple times

$
0
0
Hi! Not quite sure if this is the correct place to report bugs, but I couldn't find anywhere else, so here goes!
Pretty much as the title says, here are steps to reproduce:

i.) Create a brand new Unity project (I'm using Unity 2019.1.2.f1 on Windows 10 64-bit)
ii.) Import latest PUN2 package from Asset Store (v2.18.1 30 April 2020)
iii.) Load the "PunBasics-Room for 2" scene in the editor
iii.) Create a new 3D Cube in the scene hierarchy and position it at (0,1,0)
iv.) Add a PhotonView component to the cube
v.) Add the OwnserhipBug.cs script from here - https://forum.unity.com/attachments/ownershipbug-cs.611152/ - to the cube
vi.) Add the PunBasics-Launcher, Punbasics-Room for 1, and Punbasics-Room for 2 to the build settings
vii.) Build and Run one instance, and then play another instance in the editor

Here's the behaviour I observe:
- When the scene first loads, the photonView on the cube is owned by "Scene" (as expected)
- When the master client (i.e. whichever of build or editor joined the room first) first clicks on the cube, nothing happens - i.e. the photonview is still shown as owned by "Scene" in the editor inspector, and no logs are shown from the callback (expected behaviour would be for it to be shown as now owned by that player rather the scene, and for a log message from the OnOwnershipRequest and OnOwnershipTransferred shown in the console))
- When the other client clicks on the cube, the inspector changes to show the correct new owner of the photonView, the console log shows the debug message produced by OnOwnershipRequest and two messages produced by OnOwnershipTransferred (expected behaviour would be for a single message from
- For each subsequent click by the player who doesn't currently own the cube, an additional OnOwnershipRequest message and two OnOwnershipTransferred messages are produced. (expected behaviour - one of each)

Any assistance would be gratefully received - thanks!

How to make a players connect to a room even if it's not full?

$
0
0
I want to make a game which players can get into it and just be in the game without reaching the max players. like there will be a max of 10 players and if there will be there it will be ok too. Help?

Needing some help with VRIK (Oculus Quest)

$
0
0
I hope this isn't a repost somewhere but I looked around before making this. To give some back info I'm not new to VR development but very new to networking (Went through the tutorial).

Currently using PUN2 and VRIK to put two players in a room and see each other move. I have Photon Transform Views on my UnityXRCameraRig, Left Controller, and Right Controller targets. All VRIK values are set correctly.

However, when I join with another player they are able to see me move with my character but I can't see them move. Their player model is stuck in T-Pose. Do I need to update something in SerializeView? I'm hoping somebody can help with this. Been pulling my hair on this one lol

Let me know if uploading pics of my setup will make it easier. Thanks in advance!

-Cody

Destroying Instantiated objects

$
0
0
My instantiated player object instantiates a bullet. My script tells the bullet to destroy itself after a set amount of time. When the bullet destroys itself I get the following: "Received RPC "RPCDestroyBullet" for viewID 1015 but this PhotonView does not exist! Was remote PV. Owner called. By: #01 'Player45' Maybe GO was destroyed but RPC not cleaned up.
UnityEngine.Debug:LogWarning(Object)"

Here is my code...
void OnEnable()
    {
        StartCoroutine(DestroyBullet());
    }


    
    IEnumerator DestroyBullet()
    {
        yield return new WaitForSeconds(0.75f);
        DestroyMe();

    }

    
    void DestroyMe()
    {
        photonView.RPC("RPCDestroyBullet", RpcTarget.AllViaServer);
    }

    [PunRPC]
    void RPCDestroyBullet()
    {
        
        Destroy(gameObject);
    }

IPunInstantiateMagicCallback Question

$
0
0
Hello,

I'm trying to get Dissonance voice chat working with my UCC PUN project but am having a problem getting IPunInstantiateMagicCallback to work.

In the Dissonance demo scene the player is instantiated with:
PhotonNetwork.Instantiate(ObjectToSpawn.name, pos, Quaternion.identity, 0);

In the UCC PUN scene the player is instantiated with:
var player = GameObject.Instantiate(GetCharacterPrefab(newPlayer), spawnPosition, spawnRotation);
            var photonView = player.GetComponent<PhotonView>();
            photonView.ViewID = PhotonNetwork.AllocateViewID(newPlayer.ActorNumber);

and then i believe
PhotonNetwork.RaiseEvent(PhotonEventIDs.PlayerInstantiation, data, m_RaiseEventOptions, m_ReliableSendOption);
takes care of letting the network know of the instantiation.

However, with the latter IPunInstantiateMagicCallback is not called. Can anyone think of a way I can get it to be called when the player is instantiated?

Thanks,
Nathan

Scenes hang in Hierarchy after closing Pun basics tutorial game

$
0
0
Hello!

I'm working my way through the PUN Basics Tutorial game/demo and very much enjoying myself! I have run in to one issue that I don't understand and cannot seem to resolve.

After attempting to run my game in it's current state after the "Loading Arena From The Lobby" step, I'm seeing some strange behavior. Firstly, when I exit the game after seemingly joining the room, my Hierarchy looks like below. I am unable to remove these until the decide they've stopped loading, and when that happens seems arbitrary.

Not sure why I'm not allowed to post the image but here is a URL.
https://imgur.com/a/JLB6NdG

Secondly, my Leave Game button doesn't actually do anything. I have my Leave Room function defined in my Game Manager however clicking it elicits no reaction. I've followed everything in the tutorial thus far to the letter except for placing my newly created files into a custom namespace.

Any advice or help is greatly appreciated!

Trigger puts remote player in position at 0,0,0

$
0
0
Hello everyone, i'm using photon transform view classic since it works best in my game and i have this issue that theres a platform that has a script that puts the player prefab inside the platform so the player move with the platform.
But when they enter, the remote player of them go to 0,0,0.
This is my script and the settings of photon transform view classic and here are screenshots showing the bug:
using UnityEngine;
public class playerplatform : MonoBehaviour {
    public GameObject platform;
    void OnTriggerEnter(Collider other) {
        if (other.tag == "Player") {
            other.transform.parent = platform.transform;
        }
    }
    void OnTriggerExit(Collider other) {
        if (other.tag == "Player") {
            other.transform.parent = null;
        }
    }
}
https://imgur.com/a/YVCAXpa
https://imgur.com/a/gsVtYyQ

Restart Game problem

$
0
0
Hello,
I tried using PhotonNetwork.LoadLevel("Game");
For restarting the level. with PhotonNetwork.AutomaticallySyncScene = true; in the start function.
It seems to only work on the player calling it and not the other clients in the room.

Can someone please let me know the correct way to restart a level for all clients.

Reloading scene issue

$
0
0
Hi guys! I'm new to Photon Networking. Recently faced strange problem with scene syncing. In my project after the end of the match the scene must be reloaded. So, all the client on the same scene. What i do:
PhotonNetwork.automaticallySyncScene = true;
if (PhotonNetwork.isMasterClient)
{
            PhotonNetwork.LoadLevel(SceneManager.GetActiveScene().name); //restart the game
}
The scene is restarting only on master client. If i change scene to another, it works ok. Tell me please, is there something i do wrong? Is there some workaround except RPCs? Thank you!

High ping even with no network activity

$
0
0
Hi,

I am working on a 2D platformer-shooter with 2 players, using a Photon cloud server.

The PhotonNetwork.ping starts at around 120 and increases after a few seconds to 190-200. There is a very noticable lag, and movement is choppy especially when jumping.

Both players have synchronized transforms, rigidbodies, and animation using the Photon components.
I tried to start a game without any instantiated players, and still the ping never goes below 100.

Is this a server issue? I am located in Israel.

Thanks,
Hadar
Viewing all 8947 articles
Browse latest View live


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