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

Set interest group before joining room is an error? Was it an error before?

$
0
0
Hi. Im back to photon after probably an year or something. I just merged the multiplayer branch into the main one.
First thing I did was download the new version (1.91), and now Im testing it.
Im getting an error at joining a room:
Operation failed: OperationResponse 248: ReturnCode: -2 (Unknown operation code). Parameters: {} Server: MasterServer

The thing is, I dont remember having any errors before, so I think this is a new thing, I might be wrong.

But I dont understand the logic behind the error either.
I cant set interest groups before joining the room? Why? I should..
Since Im able to set player data before joining a room, and it will sync to other players after I join one...Why isnt the same case with interest groups?
The fact that I cant just means theres a gap between joining and setting the interest group where the server might waste band sending me stuff I dont want.
Am I wrong here?

My app is a perfect example of that. Its a stream of race events (athletics 100m, 200m..), max of 8 players, the races keep going forever, but theres no waiting for max players, 3 players might be racing while 2 just enter the room and wait for the race to finish..I dont want to send racing players data to waiting players.

Maybe Im wrong about whats going on, but I think this worked before..Heres my code:
public void JoinEmptyRoom()
    {
        if ( PUNOlympian._instance.GetState() != PUNOlympian.OperationState.standby_in_lobby )
            return;

        _lastErrorCode = 0;

        PhotonNetwork.SetPlayerCustomProperties(
            new RoomHashtable() {
                { HASH_KEYS.szPLAYER_STATE, PlayerState.waiting }
            }
        );
        PhotonNetwork.SetInterestGroups(( byte ) PlayerState.playing, false); // commenting this stops the error // calling this on the joinedroom callback also works

        PUNOlympian._instance.JoinAnyRoomWithOption(ref _options, ref _callbacks);
    }

Best way to handle bullet respawns in a multiplayer 2d Platformer shooter?

$
0
0
Hi guys i'm new to the forum, started using Photon 2 weeks ago, i love it.
This is my first multiplayer game, i know it might be too much to start with, but i wanted to give it a shot.
In my game, i might have around 10-15 players in the same lobby so you guess the amount of bullets will be kinda huge.

So instantiating them through PhotonNetwork.Instantiate is not the best choice for this. I saw you suggested using a Pool.
Checked @jeanfabre 's tutorial, but the problem is SimplePool isn't available anymore :(

How can I handle this bullet pool? Any suggestions?

Also, i read somewhere that the best way to display the bullets to everyone isn't by doing an instantiate through RPC but passing the coords of the bullet and that's all.

This is the way i'm spawning the bullets right now, without a pool:

private void Shooting()
{
if (Input.GetButtonDown("Fire1")) {
bool _usePrefabPool = true;
if (mySpriteRenderer.flipX == false) {
PhotonNetwork.Instantiate(bulletPrefab.name, new Vector2(transform.position.x, transform.position.y), Quaternion.identity, 0);
} else {
GameObject obj = PhotonNetwork.Instantiate(bulletPrefab.name, new Vector2(transform.position.x, transform.position.y), Quaternion.identity, 0);

obj.GetComponent().RPC("ChangeDirection_Left", PhotonTargets.All);
}
}
}

Thanks in advance!

Authentication Token Issues

$
0
0
Hello,
Our company uses the Photon On-Premise server.

I recently rebuilt using the batch script: "C:\Photon Server\build\deploy.prompter.bat"
After I did this I went to run my game and I keep getting the following errors:

Error 1:
NETWORK: Operation failed: OperationResponse 230: ReturnCode: 32767 (Authentication token is missing). Parameters: {} Server: GameServer => Translation: Other Error.

UnityEngine.Debug:LogError(Object)
NetworkingPeer:OnOperationResponse(OperationResponse) (at Assets/Extensions/Networking/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1623)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[])
ExitGames.Client.Photon.TPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
PhotonHandler:Update() (at Assets/Extensions/Networking/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:158)
Error 2:
The appId this client sent is unknown on the server (Cloud). Check settings. If using the Cloud, check account.
UnityEngine.Debug:LogError(Object)
NetworkingPeer:OnOperationResponse(OperationResponse) (at Assets/Extensions/Networking/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1655)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[])
ExitGames.Client.Photon.TPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
PhotonHandler:Update() (at Assets/Extensions/Networking/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:158)
Error 3(just debugging the cause from the OnFailedToConnectToPhoton() callback):
The appId this client sent is unknown on the server (Cloud). Check settings. If using the Cloud, check account.
UnityEngine.Debug:LogError(Object)
NetworkingPeer:OnOperationResponse(OperationResponse) (at Assets/Extensions/Networking/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1655)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[])
ExitGames.Client.Photon.TPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
PhotonHandler:Update() (at Assets/Extensions/Networking/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:158)
I'm not entirely sure what to make of this.
it was working previously, and I hadn't changed anything in the source, I just was curious what the batch was for, (convenience I figured) and the Auth token is assigned in two separate locations:

    internal virtual void OnConnectedToMaster()
    {
        print("NETWORK: Successful: Connected to Master.\n");
        print("NETWORK: Joining Random Room...\n");
        Debug.LogWarning("REMINDER: Create Proper Auth Values.\n");
        PhotonNetwork.AuthValues = new AuthenticationValues(DateTime.Now.ToLongTimeString());
        PhotonNetwork.JoinLobby();
        //PhotonNetwork.JoinRandomRoom();
    }
and as another check:

    internal virtual void OnJoinedLobby()
    {
        print("NETWORK: Successful: Client connected and gets a room-list - Room-list is stored in PhotonNetwork.GetRoomList()\n");
        print("NETWORK: Joining Random Room...\n");

        if (!string.IsNullOrEmpty(PhotonNetwork.AuthValues.Token))
            PhotonNetwork.JoinRandomRoom();
        else
        {
            PhotonNetwork.AuthValues = new AuthenticationValues();
            Debug.LogError("Null or Empty Photon Auth Token\n");
            PhotonNetwork.JoinRandomRoom();
        }
    }
But when debugging this, the AuthValues are empty, even after assigning it, both times.
Like I said, this used to work, and now it's not... What are your thoughts?

Large Amount of Networked Objects

$
0
0
In the application I'm working on we have a couple of huge hierarchies. Each of the objects in these hierarchies are gameobjects that the players should be able to interact with (move, grab,...) over the network. For now each of these objects has a Photon View that keeps track of a Photon Transform View and a custom script that holds some information about the object. However, some of these hierarchies are so big that we exceed the MAX_VIEW_IDS defined in the PhotonNetwork class. This is not necessarily a problem because we can just change this value but since that is never recommended, I'd like to know if there is an alternative to this situation.

One solution that came to mind was to place a script on the root of the hierarchy that would keep track of all its children and their data, minimizing the amount of Photon Views to 1 per hierarchy. Since the child objects in question remain kinetic unless a player interacts with them, we would only send this data when one of their values has changed. However, this would mean that the root script would have containers containing the information of both the local children and the remote children and constantly loop over these large containers to check for changes. Additionally, since these children do not have a Photon View, ownership will have to be handled in some other way.

I'd like to know what the common practices are when handling a large amount of networked objects. How does using lots of Photon Views compare against using 1 single Photon View that sends all the data? How would I go about this most effectively?

PUN 2.0 Transform View

$
0
0
Hello, I have updated my project to PUN 2.0 from the original version and have noticed that since the update my remote players movement appears more stuttery and jerky. I noticed that the new PhotonTransformView component no longer has any interpolate options such as lerping. Was this functionality changed or removed in the PUN 2.0 version?
Here is how my components where setup originally which looked pretty smooth and synced well.


Will I need to use a custom OnPhotonSerializeView to do the lerping now in PUN 2.0? or is there a better way to remove that stutter now?

Thank for the help!
TJ

Suddenly can't get 2 clients in the same room

$
0
0
I'm new to Photon, but everything was going just swimmingly until about an hour ago. Now all of a sudden, when I run my test code on 2 machines, each one acts as though it is the only one on the server. All counts and measures report there is only 1 player on the server, and 1 room in existence, and each one goes ahead and creates its own room.

It's not a timing issue; I have one client connected tens of seconds, or even minutes, before the other. And neither client receives an OnDisconnected until I purposely quit, so I don't think it's a premature disconnect either.

The code is simple:
	public override void OnConnectedToMaster() {
Debug.Log("OnConnectedToMaster() was called by PUN. Joining a random room.");

Debug.Log("CountOfPlayersOnMaster: " + PhotonNetwork.CountOfPlayersOnMaster
+ "; CountOfPlayersInRooms: " + PhotonNetwork.CountOfPlayersInRooms
+ "; CountOfRooms: " + PhotonNetwork.CountOfRooms);
PhotonNetwork.JoinRandomRoom();
}
public override void OnJoinRandomFailed(short returnCode, string message) {
Debug.LogWarning("OnJoinRandomRoomFailed(" + returnCode + ", " + message + ")");
PhotonNetwork.CreateRoom("");
}
public override void OnJoinedRoom() {
Debug.Log("OnJoinedRoom! I am actor number " + PhotonNetwork.LocalPlayer.ActorNumber
+ ", and there are " + PhotonNetwork.CurrentRoom.PlayerCount + " player(s), including me");
...
}
And when I run this, I see (on each client, regardless of order, timing, etc.):
  • CountOfPlayersOnMaster: 0; CountOfPlayersInRooms: 0; CountOfRooms: 0
  • OnJoinRandomRoomFailed(32760, No match found)
  • OnJoinedRoom! I am actor number 1, and there are 1 player(s), including me
Again, all this was working fine an hour ago; since then, it fails every time. I've been tinkering with code that doesn't run until much later (syncing some Photon Views), so I don't see how I could have broken it — and anyway, the code above should be all the code involved, and it's dead simple.

How do I go about debugging this?

Host and client issue

$
0
0
Hi i have a issue with my game, the host spawn the random map and after the new player who has connected doesn't have the map on his client any ideas ? I think the issue is that the masterclient spawn the gameobject but it's not sync with the client which don't have the gameobjects on his client.

https://ibb.co/kQSh5K
https://ibb.co/iKuZKe
https://ibb.co/nRu1ze

Host and client issue

$
0
0
Hi i have a issue with my game, the host spawn the random map and after the new player who has connected doesn't have the map on his client any ideas ? I think the issue is that the masterclient spawn the gameobject but it's not sync with the client which don't have the gameobjects on his client.

https://ibb.co/kQSh5K
https://ibb.co/iKuZKe

Query audio photon

$
0
0

I'm a bit new to this and would like to know how I can make another player in the scene make a sound, is it done with a rpc or does the unity component do it on its own?
sorry for my bad English

PUNRpc for himself - locally or on network?

$
0
0
When I call a method with a PunRPC attribute, if this PunRPC is my own, will I also receive a message via the network, or locally, without using the network? How is this works in photon logic?

Fast collisions with Photon Rigidbodys (Golf game)

$
0
0
I am working on a networked golf game and trying to add collision between the balls. Each player has a ball prefab with Photon components like so: https://imgur.com/VrP10Jc

As it is right now, the balls often don't register a collision when they are moving too fast, although they register fine for slower collisions. Is there any other setting that can help me register fast collisions?

An alternative is to have the master client own all the balls and simulate all the movement. However, that's not very smooth from the player's perspective because every time they hit their ball, they might have to wait 100-200 ms to see it actually move.

Any ideas welcome!

Type of games to be used with PUN or BOLT

$
0
0
Hi, excuse me if this was posted before (probably), i'm very new to photon...

What type of games that should use PUN vs type of games that should use BOLT?

For my project i'm trying to consider which is the best asset for it

Pun2 Demo - Lobby not populating the roomlist?

$
0
0
Hello and sorry if this is a duplicate, new to PUN as i am migrating from Unity networking.

I am going over the demo " Demo Asteroids", looking to learn about the lobby system implemented here.

For my game i am looking for the abilities to join a random game and create a game.

If i create a room with a build of the demo, the random mode works fine and the player connects to the room. But if i create a room and try to find the room by clicking the list button it doesnt show the created room.

Just wondering if anyone else is aware of this or know why it isnt working?

Newbie to PUN and trying to understand the API but to fresh to know where the bug maybe in the demo supplied. Otherwise this is perfect functionality for the game i have in mind.

Thanks and look forward to the replies.

Best

Daniel

Can´t get custom lobby properties working

$
0
0
So i´ve been looking a lot about this but didn´t find anything that works, I just want to show the match´s map and gamemode in lobby, here´s my code.

This is where i want to get the properties and put them in a text object:

public void Setup(RoomInfo _matchInfo, JoinMatchDelegate _JoinMatch)
{
matchInfo = _matchInfo;
matchName.text = matchInfo.Name + " " + "" + matchInfo.PlayerCount.ToString() + "/" + matchInfo.MaxPlayers.ToString() + "";

ExitGames.Client.Photon.Hashtable properties = matchInfo.CustomProperties;

matchMap.text = properties[0].ToString();
matchGM.text = properties[1].ToString();

JoinMatchCallback = _JoinMatch;
}
This is my create match method:

public void CreateRoom()
{
if (roomName != null && roomName != "")
{
RoomOptions roomOptions = new RoomOptions() { IsVisible = true, MaxPlayers = 8 };
roomOptions.CustomRoomPropertiesForLobby = new string[] { map, gamemode };
PhotonNetwork.CreateRoom(roomName, roomOptions, null);
}
}
Please tell me if you need any further information and thanks for your answers :)

Android: System.Net.Sockets.SocketException: No such host is known

$
0
0
Using PUN 2 On windows it works fine, but when I build to Android I get the following.

Connect() to 'ns.exitgames.com' () failed: System.Net.Sockets.SocketException: No such host is known

at System.Net.Dns.hostent_to_IPHostEntry (System.String h_name, System.String[] h_aliases, System.String[] h_addrlist) [0x00000] in :0
at System.Net.Dns.GetHostByName (System.String hostName) [0x00000] in :0
at System.Net.Dns.GetHostEntry (System.String hostNameOrAddress) [0x00000] in :0
at ExitGames.Client.Photon.IPhotonSocket.GetIpAddress (System.String address) [0x00000] in :0
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
ExitGames.Client.Photon.SocketUdp:DnsAndConnect()

Help me please,

$
0
0
Hi all,
Master become invisible after join room, from which I build 3 or 4 objects can you help me please?

check the video you can see the problem

https://streamable.com/rwt2v

PUN 2

$
0
0
PUN 2
As of now, PUN 2 is in the Asset Store. There are two packages (free and plus) which contain the same content, so everyone can just get and use the Free package. Upgrading PUN 1.xy Plus to PUN 2 can be done with PUN 2 Free. Get the Plus package only, if you use PUN 2 Free already and want to get a 100 CCU subscription for a one time fee.

What's new?! PUN 2 has a new structure and comes in just one "root" folder. We cleaned up the naming of many classes, fields and interfaces and there is a new callback system. We created new demos and are in the process of re-writing the documentation (note the v2 in the link). Currently the API reference is only in the package (see the PDF or CHM files). Updating existing projects will be quite some work. Here are the migration notes we took.

Existing subscriptions (e.g. of a previously purchased PUN Plus) can be used with PUN 2. There is no upgrade fee or such! If you got an existing 100 CCU subscription, you can use that. Existing AppIDs can be used in PUN 2 (and vice versa).

Why a second package then?! PUN 2 wraps up a lot of internal refactoring and includes multiple breaking changes for existing PUN projects. As we don't want to break existing projects, PUN 2 got separate packages.

Should I update? Bigger or almost complete projects should probably stick with PUN "Classic". We will keep that package around and update it but we probably won't add more features. Projects starting recently or soon, should use PUN 2.

Something is broken, right?! We tested PUN 2 in early access and with our demos but of course, there can be bugs. When reporting issues in PUN 2, please make sure to tell us you're using PUN 2 already. Reply here or mail to: developer@photonengine.com. Or post in this forum!

Why no upgrade for PUN 1 Plus?! We were unsure if we could still update the old package when we setup an upgrade path in the Asset Store. What's more important: After using the Upgrade, you would not be able to get PUN 1 Plus anymore, updated or not. So we keep things separate for the time being.

Hope you all enjoy!

Animation Triggers isn't Syncing

[PUN Classic] instantiating objects and syncing position one time

$
0
0
Hi,

Recently trying out Photon and let me say it works fantastic however as learning goes there is always issues. I have read up a bit that you should try to avoid shoving a photonview on every object so I have tried to do so however I'm having quite a few issues getting each client to recognise the position of the object without using a photon transform view. I've tried numerous things and have not got very far but here's the code I've got at the moment. Hopefully i'm not totally of from the end result however any help would be much appreciated.
    void BuildSystem()
    {
        if (buildMode == true)
        {

            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Input.GetMouseButtonDown(0))
            {
                if (Physics.Raycast(ray, out hit))
                {
                    photonView.RPC("BuildSystemNetworked", PhotonTargets.All);
                }
            }
        }
    }


    [PunRPC]
    void BuildSystemNetworked()
    {
        if (PhotonNetwork.isMasterClient)
        {
            Instantiate(blocks[0], hit.point, Quaternion.identity);
        }
    }
I mainly just one want transform.position and thats it. If i'm wrong and photonview is needed for every object i'll happily put it on however I like to make sure i'm doing the right things for the best performance.

Thanks,
Monsieur_Alpha

when RTT is too high, if i pause game(using timescale=0), is it work???

$
0
0
when rtt is too high, i want to pause game using timescale=0
after when rtt is low , i resume game using timescale = 1
is this work well????
if no, can i know how to pause game when rtt is too high
Viewing all 8947 articles
Browse latest View live


Latest Images

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