playMaker

Author Topic: Observed scripts have to implement IPunObservable [SOLVED]  (Read 1610 times)

JKWater

  • Playmaker Newbie
  • *
  • Posts: 19
Observed scripts have to implement IPunObservable [SOLVED]
« on: February 10, 2022, 12:09:09 PM »
The error:
Code: [Select]
Observed scripts have to implement IPunObservable. Player(Clone) (PlayMakerFSM) does not. It is Type: PlayMakerFSM
UnityEngine.Debug:LogError (object,UnityEngine.Object)
Photon.Pun.PhotonView:DeserializeComponent (UnityEngine.Component,Photon.Pun.PhotonStream,Photon.Pun.PhotonMessageInfo) (at .../Assets/Photon/PhotonUnityNetworking/Code/PhotonView.cs:548)
Photon.Pun.PhotonView:DeserializeView (Photon.Pun.PhotonStream,Photon.Pun.PhotonMessageInfo) (at .../Assets/Photon/PhotonUnityNetworking/Code/PhotonView.cs:534)
Photon.Pun.PhotonNetwork:OnSerializeRead (object[],Photon.Realtime.Player,int,int16) (at ...Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:1862)
Photon.Pun.PhotonNetwork:OnEvent (ExitGames.Client.Photon.EventData) (at ...Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:2233)
Photon.Realtime.LoadBalancingClient:OnEvent (ExitGames.Client.Photon.EventData) (at ...Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3353)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer)
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands ()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands ()
Photon.Pun.PhotonHandler:Dispatch () (at ...Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:222)
Photon.Pun.PhotonHandler:FixedUpdate () (at ...Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:145)

With 2 players in the same room, when instantiate a scene object with more than one fsm observed I get this error.
In the inspector it looked like it was skipping every other fsm to be observed.

MY FIX:I did a little digging and found in PlayMakerPhotonProxy.cs line 219 and line 234 it looks like it's skipping one in the loop with two i++?

Code: [Select]
            // now inject PlayMakerPhotonView where required.
            foreach (PhotonView _photonView in allPhotonViews)
            {
                Debug.Log(" photon view observing : "+_photonView.ObservedComponents.ToStringFull()+" "+_photonView.ViewID);

                Component _comp_i;
                for (int i = 0; i < _photonView.ObservedComponents.Count; i++)
                {
                    _comp_i = _photonView.ObservedComponents[i];
                   
                    if (_comp_i is PlayMakerFSM)
                    {
                        PlayMakerFSM fsm = (PlayMakerFSM)_comp_i;
                        PlayMakerPhotonView synchProxy = _photonView.gameObject.AddComponent<PlayMakerPhotonView>();
                        Debug.Log("switching observed <"+ i +">");
                        synchProxy.observed = fsm;

                        _photonView.ObservedComponents[i] = synchProxy;
                       
                    }

                    //i++; //myEdit
                }

                Debug.Log(" photon view observing job done : " + _photonView.ObservedComponents.ToStringFull() + " " + _photonView.ViewID);

            }

At "//myEdit" i commented this out and it then worked fine with no errors.

This is using Pun2 from https://github.com/jeanfabre/PlayMaker--ExitGames--PUN-2-SubModule-.

Playmaker version: 1.9.4

Attached are 2 screenshots, one of the consoles debug.logs from PlayMakerPhotonProxy.cs, and the other is the GameObject's inspector setup, with the fsms just above.
« Last Edit: February 15, 2022, 09:51:09 AM by JKWater »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Observed scripts have to implement IPunObservable
« Reply #1 on: February 11, 2022, 09:28:51 AM »
Hi.
I will ping Jean.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Observed scripts have to implement IPunObservable
« Reply #2 on: February 14, 2022, 05:54:52 AM »
Hi,

 Thanks, good catch! I never use more than one fsm to observe, so it went under my radar!

 So, yeah, of course you should have as many observed fsm as you want, but really try to refrain from that, and have all your network variables in one fsm.

Bye,

 Jean

JKWater

  • Playmaker Newbie
  • *
  • Posts: 19
Re: Observed scripts have to implement IPunObservable [SOLVED]
« Reply #3 on: February 15, 2022, 10:00:16 AM »
Yes for sure, it's always a balance between refraining from large fsms and keeping everything in one place.

I do have a manager to hold network variables but for convenience and workflow, keeping some network variables on the fsm associated with it is better.


I will submit these bug reports in unity instead if its better for you, I forgot you can do that.

[edit] Also is there a performance update for large fsms in the editor coming anytime soon? I noticed after updating playmaker from a much older version that large fsms lag when scrolling through a state with either lots of actions or just some. Where they didn't so much before.
« Last Edit: February 15, 2022, 10:05:17 AM by JKWater »