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

Game Scaling with Photon?

$
0
0
so my plan is wanted to use photon but rather than letting the players create room i wanted to have all the room instances created on my cloud server this makes my server secure. my unity instances on the server have access to the database
and all of the player side only communicates via photon.
sadly this has a side effect of having to spin up large servers with unused rooms?
is their a more efficient approach?
i'm using aws EC2 instances

error when i want to join again to a room

$
0
0
i test it with above 3 ways but get error

1- load other unity Scene and goto my first Scene and go to room again ( without any photonNetwork left room code or ... )
and get this error
JoinOrCreateRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster.

2- left room withPhotonNetwork.LeaveRoom(true); or PhotonNetwork.LeaveRoom(false); also go to my main Scene and go to my room again
and get this error
JoinOrCreateRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster.

3- left room like upper and dissconnect using PhotonNetwork.Disconnect(); and when i want to came back to the room use connection PhotonNetwork.ConnectUsingSettings("0.1"); and one time add this PhotonNetwork.JoinLobby();
and finaly get this error
ConnectUsingSettings() failed. Can only connect while in state 'Disconnected'. Current state: Connecting
but never finish the connect progress

Question on scene syncing?

$
0
0
To start off, Im new to photon as it is, and Im trying to get a hang of it, but I tend to hit a lot of wrinkles here and there. Ive been looking at the documentation, but still not entirely sure how it works. When I set the PhotonNetwork.AutomaticallySyncScene to true, does it sync all functions that will be called from the host (or master client), or does it only sync the active scene?

Reason being, Im trying to figure out if my code is fighting the other clients' code, or if the only code being ran is on the master client side.

Unity XR Interaction Toolkit and Photon 2

$
0
0
I have been trying to use XR Toolkit and Photon 2 Networking to create a multiplayer experience. When Player A grabs an object it looks fine. Player B, watching that interaction, sees the object that Player A grabbed fighting against gravity/kinestic. I have tried multiple ways to fix this but have not succeeded. Any ideas on a solution for this? Thank you in advance.

how to sync a function without an RPC?

$
0
0
How do I go about syncing a function to all clients? I believe what I'm looking for is custom properties, but I'm not really seeing how I can run a function across all clients, without using an RPC. Do I absolutely need an rpc to call a function to all clients?

It would be more convenient for me if I didn't need to call all rpc events by the players holding it. I might just have a bad setup for it, granted I'm still new to photon so I'll be making constant changes, but it would be good to know the options I have regarding sync functionality. Is this possible?

ClientTimeout when 5+ players

$
0
0
Hi there, I'm getting client timeout errors when a fifth player joins my games in photon 2.19.1. My default maxplayers is set to 5, so I thought maybe it wasn't taking that setting in properly, but when I query maxplayers it definitely shows as 10.

So the fifth player joins, and then two players are kicked from the game with a ClientTimeout error with no more details.

I can't figure out how to debug this; I would really appreciate some help. I am pretty sure I'm not doing anything wrong, but then this is first time I've tried 5+ players since I've updated to photon 2

Network Instantiating Client Objects Multiple Times

$
0
0
I have a room created that will load two players into a scene. The scene will instantiate a player object for each player, this all works correctly, however the next part is where I am not getting the expected functionality:

The player object, once entering the screen, needs a camera, and for various reasons, this camera's transform needs to be networked as well. The player object will instantiate (using PhotonNetwork.Instantiate) a networked camera object, and then map several properties of the camera object onto the player so the character controller works correctly. This all works correctly for the master client who creates the room and starts the game, however the client who joins the room, when the next level is loaded, will instantiate the player object, and the camera object, but then both players will instantiate another camera.

https://forum.photonengine.com/discussion/9878/photon-onloadedlevel-start-called-twice-on-client

this seems to be the closest thing I can find to my issue, but I don't understand what is triggering it still.

Start() called multiple times by the MasterClient

$
0
0
Hi, I've been trying to recreate the Asteroids Demo on my own and I'm having some troubles with the players instantiation. I'm having players join a lobby like in the demo, then the MasterClient use PhotonNetwork.LoadLevel(1); In this new scene I have a GameManager script with the usual unity Start() function. Inside there is
 Debug.Log("Here with " + PhotonNetwork.LocalPlayer.ActorNumber);
        Hashtable props = new Hashtable
        {
            {PlayerConst.PLAYER_LOADED_LEVEL, true}
        };
        PhotonNetwork.LocalPlayer.SetCustomProperties(props);
And if I have 3 players in my room before switching to the game scene, I can see 3 debugs with the MasterClient ActorNumber. Then the Player instanciation of the MasterClient is done 3 times as well, but it works well for the other players in the room. Seems like my GameManager has N instances for the MasterClient (where N is the number of players in the room). Anyone know what I did wrong to have this kind of behaviour ? Thanks for the help.

Which product should I choose?

$
0
0
Hi, so I'm making a multiplayer unity game which I'm planning to deploy in android and ios platforms. The way how my game is designed is to accommodate around 1000 concurrent players as of now and in future I might turn that to around 10K. Now the custom matches and custom matchmaking should be handled from the server side which means that I have to refactor the server end code according to my game so that the client code can run without any overhead. I want the multiplayer system to run as seemingly smooth and low latency as possible.
So should I use photon servers itself or should I rent a virtual server from Amazon and add the photon sdks to that?
Also my lack of knowledge couldn't perceive the purpose of Bolt, Quantum and real-time so if I can get some good insights and references that'd be super helpful.
I'm sorry about my ignorance and inexperience therefore if possible please explain without too much technical complexity.
Thanking you in-advance.

Sync problem

$
0
0
Hi,
In my game, my player is attacking the other player.

My screen:
MyScreen.jpg
The moment my player's fist hits the other player, the ragdoll takes over.

Player screen:
Player-Screen.jpg
The ragdoll gets active before my fist hits.

I thought the cause of this problem was ping but my ping value is min 15 - max 25
What is the cause of this problem?

Animations syncing problem

$
0
0
I have the following setup in my scene :
- An enviroment
- A player rigged and animated player character, controlled by Opsives First Person Controller
- 2 players

When now both players join into the game, for one player all animations gets synced and everything appears to work fine.
punissue.png
However, for one of the players (the one that first joined and or created the room) the animations are broken, resulting in T-posing and "wobbeling" (random twitching motions with interpolations and "vibration" without).
punissue.jpg

Is this a known issue ? How can this be fixed ?

Floating Point Origin w/ Photon

$
0
0
I'm running into a problem using Floating Point origin camera systems for my space flight game.

Since each player is reset back to 0,0,0 when they reach the FP threshold, Photon is updating their position to be moved back, too. How might I go about avoiding this problem? Is there a way I can ignore the position kickback for all other players except the local player? I've attached the code for the FPO camera controller.
using UnityEngine;
using UnityEngine.SceneManagement;

public class FloatingOrigin : MonoBehaviour
{
    [Tooltip("Point of reference from which to check the distance to origin.")]
    public Transform ReferenceObject = null;

    [Tooltip("Distance from the origin the reference object must be in order to trigger an origin shift.")]
    public float Threshold = 5000f;

    [Header("Options")]
    [Tooltip("When true, origin shifts are considered only from the horizontal distance to orign.")]
    public bool Use2DDistance = false;

    [Tooltip("When true, updates ALL open scenes. When false, updates only the active scene.")]
    public bool UpdateAllScenes = true;

    [Tooltip("Should ParticleSystems be moved with an origin shift.")]
    public bool UpdateParticles = true;

    [Tooltip("Should TrailRenderers be moved with an origin shift.")]
    public bool UpdateTrailRenderers = true;

    [Tooltip("Should LineRenderers be moved with an origin shift.")]
    public bool UpdateLineRenderers = true;

    private ParticleSystem.Particle[] parts = null;

    void LateUpdate()
    {
        if (ReferenceObject == null)
            return;

        Vector3 referencePosition = ReferenceObject.position;

        if (Use2DDistance)
            referencePosition.y = 0f;

        if (referencePosition.magnitude > Threshold)
        {
            MoveRootTransforms(referencePosition);

            if (UpdateParticles)
                MoveParticles(referencePosition);

            if (UpdateTrailRenderers)
                MoveTrailRenderers(referencePosition);

            if (UpdateLineRenderers)
                MoveLineRenderers(referencePosition);
        }
    }

    private void MoveRootTransforms(Vector3 offset)
    {
        if (UpdateAllScenes)
        {
            for (int z = 0; z < SceneManager.sceneCount; z++)
            {
                foreach (GameObject g in SceneManager.GetSceneAt(z).GetRootGameObjects())
                    g.transform.position -= offset;
            }
        }
        else
        {
            foreach (GameObject g in SceneManager.GetActiveScene().GetRootGameObjects())
                g.transform.position -= offset;
        }
    }

    private void MoveTrailRenderers(Vector3 offset)
    {
        var trails = FindObjectsOfType<TrailRenderer>() as TrailRenderer[];
        foreach (var trail in trails)
        {
            Vector3[] positions = new Vector3[trail.positionCount];

            int positionCount = trail.GetPositions(positions);
            for (int i = 0; i < positionCount; ++i)
                positions[i] -= offset;

            trail.SetPositions(positions);
        }
    }

    private void MoveLineRenderers(Vector3 offset)
    {
        var lines = FindObjectsOfType<LineRenderer>() as LineRenderer[];
        foreach (var line in lines)
        {
            Vector3[] positions = new Vector3[line.positionCount];

            int positionCount = line.GetPositions(positions);
            for (int i = 0; i < positionCount; ++i)
                positions[i] -= offset;

            line.SetPositions(positions);
        }
    }

    private void MoveParticles(Vector3 offset)
    {
        var particles = FindObjectsOfType<ParticleSystem>() as ParticleSystem[];
        foreach (ParticleSystem system in particles)
        {
            if (system.main.simulationSpace != ParticleSystemSimulationSpace.World)
                continue;

            int particlesNeeded = system.main.maxParticles;

            if (particlesNeeded <= 0)
                continue;

            bool wasPaused = system.isPaused;
            bool wasPlaying = system.isPlaying;

            if (!wasPaused)
                system.Pause();

            // ensure a sufficiently large array in which to store the particles
            if (parts == null || parts.Length < particlesNeeded)
            {
                parts = new ParticleSystem.Particle[particlesNeeded];
            }

            // now get the particles
            int num = system.GetParticles(parts);

            for (int i = 0; i < num; i++)
            {
                parts[i].position -= offset;
            }

            system.SetParticles(parts, num);

            if (wasPlaying)
                system.Play();
        }
    }
}

Would a small scale loot and shoot work with PUN?

$
0
0
I have been using PUN 2 for a while but still have a hard time wrapping my head around the amount of messages produced by a room. I am thinking about a game with around 12 players per room and a relatively low amount of rpc calls (only when a player shoots a weapon and ammo is rare or loots something etc.) All npc's would be handled locally on each client. Do you think this idea would be able to fir PUNs restrictions?

Disconnection after loadScene

$
0
0
Hello, When i try to load a new scene some time it disconnects me from the room after loading the scene.
My code :
public override void OnJoinedRoom() {
// Debug.Log("Vous etes dans la Room");
PhotonNetwork.LoadLevel("MyGame");

}
-I am using Unity 2020.0f1
-The last version of Pun 2

How does it work? (See more below)

$
0
0

The way i think it works is that the photon cloud servers handle the rooms but the game code runs on the host client and the other clients. Does the PUN server use punchthrough and relay if it fails? Or is messages always relayed through photon and the rooms? Thanks in advance 😄


Can I send custom packets through PUN?

$
0
0

I would like to separate game objects and logic from networking so I would like to do my own network packets and loose the auto sync scripts ;)
Thanks In advance

Help, Parties and teams on matchmaking

$
0
0
I'm trying to see how I can create a matchmaking that takes into account the number of players and their assigned team when I have to join a game being 2 or more people in the party.

That is, once within the game the teams are divided into two 5vs5 teams, (red team and blue team), if I join whit a friend in which for example a room there are only 4 players, I can manually assign that one team is 4 people and the other 2 (to keep my friend and I on the same team), but if I join a game in which there are only 2 slots left, it would end up being a 4vs6 or a 5vs5 , but my friend and I would not be on the same team, I want to avoid both things .

So, any idea of how in the matchmaking I can take into account the members that we are in the party and the distribution of the teams?

Thank you, Sry for my english

Syncing Video Time Over Server?

$
0
0
I am stuck on trying to sync the time of the video for players who join the room after the video has already played. I have an RPC that plays the video, and sets the time to the current video time in a variable set locally. The RPC is set to all buffered. However, the video always starts from the beginning. I tested that I was setting the time correctly by setting it locally every three seconds to the current time, and it works. Any ideas on how to successfully sync the time of the video in Unity using PUN2 and the Video Player?

Multiple rooms question

$
0
0
Hey, total beginner question but I would really appreciate some direction at the moment.

What I am hoping to do is have a lobby that allows players to enter multiple scenes, each completely unrelated to one another. Am I able to do this where each scene is run from a different client?

I guess my question is how do I facilatate giving the user multiple options for scenes to load into? If anyone can point to any documenation or examples for this I would be most grateful. I'm a bit unsure about the terminology and my searches haven't been very helpful.

Thank you in advance,
Nathan

PUN for WebGL build error : Deserialization failed for internal Operation Response. System.Exception

$
0
0
My project was working fine while on Android platform. I switched to WebGL platform for HTML5. Protocol is set to Web I tried to connect to Photon Network. Can any one suggest how to fix this and make existing
Deserialization failed for internal Operation Response. System.Exception: Deserialize(): 7 pos: 6 bytes: 55. F3-07-01-FF-FF-07-2F-4D-69-73-73-69-6E-67-20-76-61-6C-75-65-20-31-20-28-50-69-6E-67-52-65-71-75-65-73-74-2E-43-6C-69-65-6E-74-54-69-6D-65-53-74-61-6D-70-29-0D-0A-00
  at ExitGames.Client.Photon.Protocol16.Deserialize (ExitGames.Client.Photon.StreamBuffer din, System.Byte type) [0x0021b] in <7c99d57ff1b84df1ab45b8023b1063e2>:0 
  at ExitGames.Client.Photon.Protocol16.DeserializeOperationResponse (ExitGames.Client.Photon.StreamBuffer stream) [0x0002b] in <7c99d57ff1b84df1ab45b8023b1063e2>:0 
  at ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) [0x0030d] in <7c99d57ff1b84df1ab45b8023b1063e2>:0 
UnityEngine.Debug:LogError(Object)
NetworkingPeer:DebugReturn(DebugLevel, String) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1620)
ExitGames.Client.Photon.<>c__DisplayClass104_0:<EnqueueDebugReturn>b__0()
ExitGames.Client.Photon.TPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:161)
Viewing all 8947 articles
Browse latest View live


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