Players are seemingly accessing the same Singleton

Options
I have a issue that I am trying to solve... noob at pun with a little experience in the past (years ago) just getting back into the swing of things again....

PhotonNetwork.ConnectUsingSettings( "1.52" );
Unity 5.01 Pro
WebPlayer Build

my issue is when I have 2 players in a room and 1 players controller is accessing a Singleton to check the current game state it seems that the other player is also checking the same Singleton...In this singleton class I have references to most of the players commonly used objects... gamesystem class, ref to players controller .. etc etc.

I do have a PhotonView with a Observed Component being the main player class.... I think this is the issue...

in my code I also have the player class declared like so
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using Hashtable = ExitGames.Client.Photon.Hashtable;

public class PlayerSystem : Photon.MonoBehaviour { ...}

so in my gamesystem I have a camera check that changes zoom based on the players rigidbody values.. and well.. if one players rigidbody value changes and a check takes place.. .the other player in the room's camera also changes....

I have this camera change code taking place in a gameSystem class that isn't Observed by a photon view... except the PlayerSystem is being observed and does change a singleton value that is being referenced by the CameraSystem....

Seems that I am using this main player class as a base for each player.... but the values are not being separated on a per player basis like I thought they would be...

I have done some
if (photonView.isMine) { ... }

to block out code so that it isn't ran on all clients.. but seems I am just not doing this correctly... any suggestions would be welcome...

Update: My issue was resolved by not Observing the main class that had all the singleton refrences. I seperated all network demanding code from players controller and observed this secondary class. I think i have a handle on this.

Thanks!!

Comments

  • Tobias
    Options
    Thanks for the update!
  • Ernie
    Options
    Has anything changed in how Photon works with Unity 5? The issue above might be related to my issue: I have a player with a network view and an observed network script. The player also has an inactive script that is for local control and is set active by the local user only. But I see that functions within that script are being executed by the remote versions of that player, even though I can see that the script on those remote players are not active. How can that be?
  • yeah i was going bonkers trying to figure this out... my solution was to not Observe the script.. and to make a secondary observable script that is focused around specialized photon related logic that I need in the game....

    So lets say I have a manager script that is a singleton being referenced directly from the singleton things just end up happening on local and remote players... made for some interesting coding sessions....