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

Best Practice VR Multiplayer?

$
0
0
Hello Forum!

I've tried for quite a while to get a properly functioning VR setup, but are running into some problems.
I managed to set up a room and track the headset rotation + position, but struggeling with the position of the controllers.
I might have done this completely wrong, and it feels like i've done this completely inefficient, so maybe someone knows a better way to do this!
What i have:

For the Body

public class NetworkedBody : Photon.MonoBehaviour {

    public GameObject avatar;
    public Transform playerGlobal;
    public Transform playerLocal;

    void Start() {
        if (photonView.isMine) {
            playerGlobal = GameObject.Find("OVRPlayerController").transform;
            playerLocal = playerGlobal.Find("OVRCameraRig/TrackingSpace/CenterEyeAnchor");
            avatar.transform.SetParent(playerLocal);
            avatar.transform.localPosition = Vector3.zero;
            // avatar.SetActive(false);
        }
    }

    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info){
        if (stream.isWriting){
            stream.SendNext(playerGlobal.position);
            stream.SendNext(playerGlobal.rotation);
            stream.SendNext(playerLocal.localPosition);
            stream.SendNext(playerLocal.localRotation);
        }
        else {
            transform.position = (Vector3)stream.ReceiveNext();
            transform.rotation = (Quaternion)stream.ReceiveNext();
            avatar.transform.localPosition = (Vector3)stream.ReceiveNext();
            avatar.transform.localRotation = (Quaternion)stream.ReceiveNext();
        }
    }
}
For the Left Glove
public class NetworkedLeftGlove : Photon.MonoBehaviour {

    public GameObject leftGlove;
    public Transform playerGlobal;
    public Transform playerLocal;

    void Start(){
        if (photonView.isMine){
            playerGlobal = GameObject.Find("OVRPlayerController").transform;
            playerLocal = playerGlobal.Find("OVRCameraRig/TrackingSpace/LeftHandAnchor");
            leftGlove.transform.SetParent(playerLocal);
            leftGlove.transform.localPosition = Vector3.zero;
            // avatar.SetActive(false);
        }
    }

    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info){
        if (stream.isWriting){
            stream.SendNext(playerGlobal.position);
            stream.SendNext(playerGlobal.rotation);
            stream.SendNext(playerLocal.localPosition);
            stream.SendNext(playerLocal.localRotation);
        }
        else {
            transform.position = (Vector3)stream.ReceiveNext();
            transform.rotation = (Quaternion)stream.ReceiveNext();
            leftGlove.transform.localPosition = (Vector3)stream.ReceiveNext();
            leftGlove.transform.localRotation = (Quaternion)stream.ReceiveNext();
        }
    }
}
And basically the same for the right glove.
The gloves seem to move only a little bit of the distance needed.
What is a better aproach for this?

Has anyone tried to serialize Oculus Avatar?

$
0
0
Hi all, I'm just ramping up on both Oculus Avatar and Photon. I've been reading the getting started tutorial. Is it possible to use the PhotonView scripts to automatically serialize an Oculus avatar?

Game host build freezing randomly (but very often) (losing my mind!) with PUN

$
0
0
I've spent a week banging my head trying to figure out what the problem is. Every time I thought I isolated it to particular code and fixed it, it would freeze. This led me to believe it was something overall with Photon/PUN.

Here is a video example:
https://screencast-o-matic.com/watch/cFhZoKbmKF

What happens:
I run two client executables of the game. One client creates the room, the other client joins it.


The first two times I do this, it runs perfectly. Each time I exit out of the builds.


The third time, the client that created the room locks up and crashes the build.


There is no flow for reproduction. Sometimes its the second time I run the build. Sometimes the first. Sometimes the third. But at some point, the creator build always locks up. Same thing happens whether I'm in the Unity editor or a compiled build. I can barely even playtest my game because the Unity editor freezes constantly.

I tried a Disconnect() when the Application quits, in case it was some cleanup issue, but that doesn't help.

Build with: Unity 2017.3.1f1
PUN version: 1.90 (currently using the Free version from the Asset Store until I release the game)

Link to download the compiled build if that helps:
https://drive.google.com/file/d/1b3gYdFBizq_JmsfcUcfPtjNGnw-JxdJC/view?usp=sharing

Help would be greatly appreciated! I'm not sure what is left for me to do to try and debug this.

Between rooms

$
0
0
There are two people in the room - First-in and Second-in. When the first one enters another room with enemies having a Photon View script, they are all initialized. But if the second one enters the first room to go to the next room, it becomes empty (not one enemy), only the character himself. I want to note that enemies with zero health value do not die, but become passive. And the characters enter the next room alone. I need to fix this problem, and make it so that if the second one enters the room, manages to pass to the first team for the first time, then the enemies do not disappear.
P.S: For transition between scenes I used Application.LoadLevel, and in each scene reset PhotonNetwork.LeaveRoom (); and changed PhotonNetwork.JoinOrCreateRoom (Application.loadedLevelName, new RoomOptions (), TypedLobby.Default); so, with this there is no problem.


Having a global script that handles the current game state etc.?

$
0
0
Hello,

Just got into Photon Networking after some struggling with UNet and I enjoy it so far. However, I have a question regarding handling the gameplay. Here's a simplified breakdown of what I want to achieve:
  1. Multiple users in a room
  2. Users can send input to the 'server' (single script somewhere that controls the game?)
  3. Server checks if it wants to process the input from the user
  4. Server moves an object
I'm basically looking to control one character in the scene with multiple users in the room. Users can only control the character in certain conditions.

Could anyone enlighten me on the process I'd have to make/think of?

Thanks in advance.

My messages/s isn't showing up anymore in my dashboard?

Photon Cloud, room properties?

$
0
0
I am having trouble understanding something.
Is it not possible to update room properties via webhooks?
If not, what exactly then is the use case for photon cloud vs photon server, as their appears to be no way to do any kind of server logic, and everything is client authorative?

Please correct me if I am wrong here.

Ultimately all I want to is have a client fire off a webhook to check if an item is available for them to “pick up” and if it is, flag it as no longer available if they do get it.
I’d prefer the server be able to determine this, not the client.
Is there an alternative to room properties that could be utilized for this, or do I need to run an actual server and cloud/webhooks are insufficient?

Thanks

How to smoothen out ball movement over network

$
0
0
Hi, I am making an online 2D soccer game using Photon and need help getting the ball's movement to be smoother. I have already set up the player movement but when the ball moves it is very glitchy and jumps around a lot. I have the following code on the ball:

public class ballMoveNetworking : MonoBehaviour {
Vector3 targetPos;

PhotonView PhotonView;

// Use this for initialization
void Start () {
PhotonView = GetComponent ();

}

// Update is called once per frame
void Update () {
if (!PhotonView.isMine) {
smoothMove ();
}
}


private void smoothMove(){
transform.position = Vector3.Lerp(transform.position, targetPos, 0.25f );
}



private void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info){
if (stream.isWriting) {
stream.SendNext (transform.position);

} else {
targetPos = (Vector3)stream.ReceiveNext ();

}
}
}


This script is in the 'Observed Components' option in a Photon View Component on the ball.
Thanks in advance.

"Receiving failed. SocketException: ConnectionReset" in a clean project Unity 2018.1.1f1

$
0
0
I would like this removed. Because I created a new one as a question

Hey
Am Geting
Receiving failed. SocketException: ConnectionReset
UnityEngine.Debug:LogError(Object)
NetworkingPeer:DebugReturn(DebugLevel, String) (at Assets/AssetStore/Exit Games/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1572)
ExitGames.Client.Photon.<>c__DisplayClass99_0:b__0()
ExitGames.Client.Photon.TPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
PhotonHandler:Update() (at Assets/AssetStore/Exit Games/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:153)


in a clean project of Unity 2018.1.1f1
All I do is t"ry to connect using PhotonNetwork.ConnectUsingSettings("0.3"); in void Start()



My logs
https://drive.google.com/file/d/10xtj-y91612hGqhfs3Ush8s2F_RFg6AN/view?usp=sharing

thanks in advance !

Sincerely Johan

Photon Animator View not working

$
0
0
Hello

In my game I want to synchonise my animator over the network, but it seems like my photon Animator doesn't want to work, I have no errors in the console eveerything works fine (photon transform view and other photon components) but photon animator view doesn't seem to work.

I got it working once, I came back two minutes after and it wasn't working anymore.

I'm working with Unity 2018.1.1f1



Photon Handler Dispatch Incoming Commands HIGH CPU USAGE

$
0
0
I have a serious issue with photon. After running the profiler I can see that Dispatch Incoming Commands is at 90%+ and makes my game unplayable. Why is this happening? Please help me.
I can't play my game with anyone after somebody joins besides me I lag brutally.

PhotonNetwork.ReconnectAndRejoin(); Create new PhotonView and destroying older Photon View

$
0
0
Hello,
When user disconnects by unexpected network error we are using PhotonNetwork.ReconnectAndRejoin(); in same scene..

we are able to rejoin to same room, But the problem is photon is destroying existing players photonviews. and instantiating new views..

How to reuse same photonviews which are already avialble in same scene and room..

Game state is preserved in Players PhotonViews like player health and weapons etc.

How to prevent auto instantiation happening from Photon on rejoin..?

Why it is destorying existing Views as these are already owened by Player and avaible in same room.

How to fire a weapon?

$
0
0
Hi,

I have a prefab of my player with PhotonView component and in his bone hierarchy I have a gun attached to the spine_02. The gun has a RifleManager.cs script added to control all the gun functions and properties. The player shoots the gun with a script attached (PlayerShoot.cs), but the shooting function is in the RifleManager.cs (called from the PlayerShoot.cs script). A Projectile is spawned. I want to make it spawned in network. Do I need to add another PhotonView component to the gun attached to the player? I think, I don't. How to do that in Photon?

It takes time when I re-enter the same game-room

$
0
0
I am developing a Unity game app with PUN.
My problem is... at first, two players are OK with getting into the game. However, when one of them gets out (using PhotonNetwork.LeaveRoom()) and tries to re-enter the same game-room (using PhotonNetwork.JoinRoom(room name)), it takes a while. And it takes longer as you try again. Sometimes it doesn't even move at all.
Please help me. The source code about entering the game_room is here...
I am using Unity 2017.3.1f1. Thanks.
-------------------------------------------------------------
public void PlayGame() {
    foreach(RoomInfo ri in PhotonNetwork.GetRoomList()) {
        if (ri.PlayerCount < ri.MaxPlayers) {
            PhotonNetwork.JoinRoom(ri.Name);
            break;
        }
    }
}

void OnJoinedRoom() {
    ...
    StartCoroutine(Battle_Scene());
}

IEnumerator LoadBattleField() {
    PhotonNetwork.isMessageQueueRunning = false;
    AsyncOperation ao = SceneManager.LoadSceneAsync("Battle_Scene");
    yield return ao;
}

photon view id duplicate

$
0
0
Hi there,
I have 2 scenes, a menu scene and a game play scene. In both scenes I have a couple of objects that use the Photon View component as it's needed for some RPC calls. One of the objects in the menu scene has a "dont destroy on load call" so it persists through scene change. When I move from the menu scene to the game play scene, I get the "photon view id duplicate" because both the object that persists and one of the objects already existing in my game play scene share the same Photon View ID 2.

I tried to go in my game play scene and manually change the Photon View ID for the objects that already exist there but it's not working, it gets defaulted back as soon as I try to apply the changes to the prefab. I read somewhere that PunSceneSettingsFile might be of help, but I'm not sure what to do with it.

My question is, how can I change the Photon View ID manually inside the scene and if I can't, what else can I do?
Thanks!

Fast bytes exchange between 2 players

$
0
0
Hello,

I just started to learn PUN. I started with documentation, but I find it extremely confusing.
I would like to ask if it is possible to use PUN for the following scenario:
I would like to join two players in one room. Each player should have ability to send explicitly bytes array to another player. In essence, I just need:
- some method "Send" which can be called in each "Update" method (60 times per second) to send bytes array to remote player
- some method "Receive" (or event "OnReceived") which can be used to receive bytes array from remote player (60 times per second)

Is there a way to achieve this using PUN? In the documentation I found only "Photon View" script which observes objects and somehow send changes. I need more control over messages exchange process.

best regards,
Radik

Question about traffic overflow

$
0
0
value = (PhotonNetwork.time - info.timestamp)
this value does not change around 1 ~ 500 messages per second? ....1~800 too ? :o

...This means that the limit of 500 messages is simply the load of the processor from the processing of more expensive operations PhotonNetwork.Instantiate(this operation is more costly than https://docs.unity3d.com/ScriptReference/Object.Instantiate.html), PhotonNetwork.Destroy(this operation is more costly than https://docs.unity3d.com/ScriptReference/Object.Destroy.html), etc.

From this it follows that In PUN there is only one concept of traffic overflow.
This is only when the photon server manually ejects one player from the room (when there are 800~1000 messages per second in the room)

A client joining the Master Client in game is doubled

$
0
0
Hi,

As the title says, I create a room with the Master Client, and then I start the second instance of game as an ordinary Client and player is doubled (now, there are three players visible and the two are controlled by the Master Client).

CCU and Rooms counted twice

$
0
0
Hello,

I have a weird issue with the analytics available in the "realtime" session of the PhotonEngine Website.

All my CCU and rooms created are counted twice...

When I create room and connect two players to it, the analytics say that I created 2 rooms and I have a CCU of 4

What could cause such an issue? Would that mean that if I connect 10 players I already reach the 20 CCU limit?

Thank you for your help!

PhotonNetwork.CloseConnection(PhotonPlayer _player)

$
0
0
I have a question about this function. It works as expected, but I cannot figure out one thing. How can I determine on the client of the kicked player that it was a kick from Master Client and not any another reason?... Thanks for help!
Viewing all 8947 articles
Browse latest View live


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