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.

Invisible players bug

Sylvine
2015-09-24 16:34:44

It's gonna be a tough question because my game is getting more and more complex, and I don't know for how long this problem was here.
I'm using the last version of Unity Personnal Edition, and the free version on PUN, and it's a PC game.

It's a multiplayer shooter, let's say it's round base so the game wait for having enough players before starting the round. Before that there is a warmup where player can still play to wait.
At first my game was very simple, it just makes players respawn as soon as they join the server and everything was fine.
Then I've added more and more things like teams and this round thing, so for testing purpose I made that the round start even if there are not enough players.

Now I reactivate all the warmup pre-round code.
The strange thing is that sometimes (and when I say sometimes, it's more always, but not always at the same point), players joining afterwards can't see the others players (while the players that were there before can see him). At this point, everyone joining after that won't be able to see the other players, but they can see the players joining after.
Let's say we a 5 players A, B, C...
A create the room.
B connects, he can see B and A can see him.
C connect; he can't see nobody but A and B can see him.
D connect, he can't see anybody, but A, B and C can see him.
...
But I'm sure the players are sync in the room, they can be shot by players they can't see, they can see their names on the score board...

If all the players vote to start the match, the game make everybody respawn, and then it's fine, everybody can see everybody.
At first I thought it was a problem with Unity, and I start deactivating things in my code to find the problem, but I didn't find anything.

What's more strange is that the problem is very random, sometimes the problem starts with the second player, sometimes it's with the third one (I haven't seen it working after 3 players). Sometimes I think I can see a pattern, something like if the first player joins this team it's going to work, but then I change a line in the code and rebuild the game and I don't get the same results.

But the strangest thing is that if I connect using the player in the Unity editor, it's always working (that's one on the reason I haven't seen this bug earlier).

That's it, I can show you parts of the code if you want, but since I've really no idea from where it's coming I'm not sure it will help.
I'm hoping this a common issue related to photon and you may help me.

Comments

bananashavings
2015-09-26 01:18:00

Are you changing levels. If so are you using PhotonNetwork.LoadLevel();?

Sylvine
2015-09-26 10:24:49

@bananashavings wrote:

Are you changing levels. If so are you using PhotonNetwork.LoadLevel();?

Well, it's funny, I was trying to use PhotonNetwork.LoadLevel() when I noticed the game wasn't working properly.
But no, the problem is not here, this line of code is not read at the moment the problem occurs, and anyway it's one of the first thing I've removed to see if the problem was here.

But now you're talking about changing level, it makes me thing I've got this warning :
UnityEngine.Application.isLoadingLevel is obsolete: This property is deprecated, please use LoadLevelAsync to detect if a specific scene is currently loading.
It's about this part of the photonview script :
protected internal void OnDestroy()
{
if (!this.destroyedByPhotonNetworkOrQuit)
{
PhotonNetwork.networkingPeer.LocalCleanPhotonView(this);
}

Sylvine
2015-09-27 17:47:09

I've just found this : http://forum.unity3d.com/threads/script-not-working-in-build-ok-in-editor.40806/

It seems sometime with Unity the game can be working fine on the editor but not on the build version (which is exactly my problem).
Before that I wasn't paying to much attention with some error messages, but now I've tried to remove some part of my code that was causing these error messages and it seems to be working.

But there is this error message I've got as soon as the game is running :

NullReferenceException: Object reference not set to an instance of an object TeamExtensions.GetTeam (.PhotonPlayer player) (at Assets/Photon Unity Networking/UtilityScripts/PunTeams.cs:84) PlayerNetworkMover.Start () (at Assets/Script/PlayerNetworkMover.cs:48)

Sylvine
2015-09-27 21:41:56

@Sylvine wrote:

I've just found this : http://forum.unity3d.com/threads/script-not-working-in-build-ok-in-editor.40806/

It seems sometime with Unity the game can be working fine on the editor but not on the build version (which is exactly my problem).
Before that I wasn't paying to much attention with some error messages, but now I've tried to remove some part of my code that was causing these error messages and it seems to be working.

But there is this error message I've got as soon as the game is running :

NullReferenceException: Object reference not set to an instance of an object TeamExtensions.GetTeam (.PhotonPlayer player) (at Assets/Photon Unity Networking/UtilityScripts/PunTeams.cs:84) PlayerNetworkMover.Start () (at Assets/Script/PlayerNetworkMover.cs:48)

Ho...

Without noticing it I drop the player prefab on my scene, that's where the message error come from (this player prefab is owned by no one, so photon can get its team).

Back to top