The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Restricting joining room with non-matching game version

jarileon
2019-01-24 12:45:03

I have a simple online game created with Unity. Now, I wanted to test joining the same game room from a build from totally different Unity project (but the Photon app ID is the same in both projects) - and to my surprise, it worked - even though I have PhotonNetwork.GameVersion set to different values in each project.

The docs for PUN2 says: "In the Photon Cloud, the GameVersion string is used as simple way to isolate builds (and players) from one another, without changing the AppId. Change the GameVersion when when making breaking changes to the network logic to keep players of different versions apart."

What am I missing? I would have supposed that it is not possible to join if the GameVersion does not match.

I set the GameVersion just before I call ConnectUsingSettings(). I am using pre-named non-visible room which I join with PhotonNetwork.JoinRoom("SecretRoom");

Comments

JohnTube
2019-01-24 13:46:23

Hi @jarileon,

Log the PhotonNetwork.NetworkingClient.AppVersion inside OnConnectedToMaster from both clients.

jarileon
2019-01-25 08:17:43

@JohnTube I did that. Both clients print "0_2.5" So they match, which explains why joining the room is possible. But it seems the version appended to the AppVersion (0) is the PUN version (2.5) and not whatever I have set to the GameVersion (which is "v1" for the other one and "v2" for the other). Is this a bug in PUN2 or am I missing something?

JohnTube
2019-01-25 10:41:54

Hi @jarileon,

Find all references to PhotonNetwork.GameVersion to see when this value is changed.
I did a quick test:

using Photon.Pun;  
using UnityEngine;

public class testAppVersion : MonoBehaviourPunCallbacks
{
// Use this for initialization
private void Start ()
{
PhotonNetwork.PhotonServerSettings.AppSettings.AppVersion = "editor";
PhotonNetwork.GameVersion = "before";
PhotonNetwork.ConnectUsingSettings();
PhotonNetwork.GameVersion = "after";
}

}

So you can either:

  1. set AppVersion from the Unity Editor, in the PhotonServerSettings ScriptableObject. That will be used as PhotonNetwork.GameVersion inside PhotonNetwork.ConnectUsingSettings()
  2. set PhotonNetwork.GameVersion after calling PhotonNetwork.ConnectUsingSettings()

We will address this in PUN2 either in docs or in a future update.

jarileon
2019-01-25 14:55:08

@JohnTube ok I did some more testing. Like you said, it seems that GameVersion only matters (= allows joining a room only if they match) only if you set it AFTER calling ConnectUsingSettings(). I would say this is somewhat weird and unexpected behavior, as usually you set values before you call a function that does something with those values. Also having both AppVersion and GameVersion is somewhat confusing, maybe there is room for simplification in this.

Psyco
2020-05-05 09:35:16

Just ran into the same issue.
The sample code provided by photon is then incorrect :

Please fix the product that some of us pay for

Jerem
2021-04-29 13:31:55

Hi

I'm experiencing the same issue, different game versions can join. I tried many things, like define game version in the PhotonServerSettings ScriptableObject, set it before and after calling PhotonNetwork.ConnecUsingSettings(). I debug client version and it is different but they can join the same room. I am not using Photon Cloud for hosting but a personnal server.

Someone found any solution ?

I am with Unity 2020.2 and Photon 2.30

JohnTube
2021-04-29 14:58:36

Hi @Jerem,

Thank you for choosing Photon!

This is not available in self-hosted Photon Server. Only on Photon Cloud.
You can check the full differences here.

You could try to add this yourself in server code.

strangegames
2021-05-14 14:28:23

@JohnTube I found this while looking up when to set PhotonNetwork.GameVersion. Your comment about this being fixed in Pun2 which I'm now using makes me wonder if we still should set it after calling connect.

As someone else mentioned, this seems wrong to set an important parameter after calling connect() so I wanted to make sure this is still how we're supposed to do this.

Thanks

JohnTube
2021-05-14 14:45:07

Hi @strangegames,

The correct proper expected way is to set it before connection call in ServerSettings either via Unity Editor in compile time by changing the respective field in PhotonServerSettings ScriptableObject inspector or via code PhotonNetwork.PhotonServerSettings.AppSettings.AppVersion.

strangegames
2021-05-14 15:35:02

Hi @JohnTube
Thanks for the quick reply. We have multiple Unity projects (one for each build platforms) so setting it via code is better since version control populates it correctly across all platforms. This was our old way.

According to what you're saying, we should actually be doing this then?

JohnTube
2021-05-14 23:33:09

Hi @strangegames,

According to what you're saying, we should actually be doing this then?

Yes exactly!

Back to top