Search Unity

Third Party Photon Unity Networking

Discussion in 'Multiplayer' started by tobiass, Aug 23, 2011.

  1. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
  2. neounix

    neounix

    Joined:
    Jan 9, 2017
    Posts:
    28
    Hey Photon!

    Quick hopefully not too dumb question.

    We use Unity Plus and have it set up for multiplayer, testing a UNET app using the OOTB Unity NetworkManager and HUD component. My app is starting to work, at least when I test on the same computer, one build running and another in the editor. However, like many others, I want to debug and have access to the editor for both client and server builds when testing on two machines on the same LAN. My setup is pretty basic, both computers are on my local WIFI with 192.168.2.100 and 192.168.2.200 addresses for each computer. Man! I've been trying for hours and cannot get this to work on the LAN in this setup. The client does not connect to the server and debugging is nearly impossible, or so it seems to me, due to restrictions with how Unity implements multiplayer.

    After a lot of reading and net searching, I see Photon is recommended to get around this problem.

    Is that right, oh Photon Gods of Unity?

    I have years of experience in networking, Linux and MacOS, Unix, etc, so I'm comfortable with networking; but I cannot get UNET working on the LAN on separate machines for testing! It's killing me!
     
    Last edited: Apr 30, 2018
  3. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,068
    @neounix: So, when you attach the debugger, you can't connect client and server? Could this be a problem with some manifest and "capabilities"?

    You could check with Wireshark if the client even sends anything in this case.
    Maybe you can attach the debugger to a running instance after it connected? I think this was someone's workaround for similar issues.

    In general, you can debug Photon clients but any breakpoint stops the client (and or the server) and timeouts usually kick the connection before you found what you needed to see. In Photon, you can work around this by using a TCP connection, running your own server and setting all timeouts to very high values.

    However, Photon is quite different from uNet, so switching may be quite some effort. Aside from Bolt, all Photon packages connect via a distinct server, which does not know Unity's content (scene, instantiated objects, etc), so this may be a big shift for you.
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,068
    Hey everyone.
    As you may know, we're working on a bigger update for PUN and there's now a new Early Access package.
    This is maybe not yet production ready but stable enough to get to know it. PUN 2 is hopefully much cleaner and better already: New namespace, clear folder structure, better performance.

    Find more info about this package and a discussion about it in our forum.
    Please let us know what you think - please reply in our forum.
     
    Liminal-Ridges likes this.
  5. neounix

    neounix

    Joined:
    Jan 9, 2017
    Posts:
    28
    @tobiass

    Thanks. Actually, I think the problem is that I come from a UNIX/Linux client/server background, and very little in the Unity UNET and LLAPI world makes sense. For example, Unity calls creating a socket in Unity LLAPI (TLAPI) NetworkTransport.AddHost() , but this has nothing to do with adding a Host, it's just creating and I assume binding to a socket.

    I have a similar problem with NetworkTransport.Connect(), which seems to only work properly if the socket is on the same host and not a remote server; as if Connect() is actually binding the socket.

    It's easy to write debug statements and debug, but the problem seems to be in the Unity networking internals... I mean if Unity understood networking why would they call CreateSocket() AddHost() ??
     
  6. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,068
    Well, I obviously can't speak for Unity but I think it makes sense. The LLAPI is not just creating a Socket. AddHost will do much more than that. You see, connecting players don't just send you raw datagrams, so there is a protocol to "initialize" a session/game, once the transport layer established the connection. AddHost prepares your app to accept said connections.
    Now I fear you would be lost with PUN / Photon as well. We also have "connect" methods, which do much more than binding a socket.
     
  7. neounix

    neounix

    Joined:
    Jan 9, 2017
    Posts:
    28
    @tobiass

    LOL, I began coding client / server in C in the year 1987 or 1988 and have been coding ever since, so generally the only time I am confused or lost about interprocess communications or APIs is when APIs are poorly written or poorly documented.

    Respectfully, I think you are confused or mixing up your replies, somehow... because LLAPI does not "do a lot more than transport" it is basically only a transport layer API, and all the "extras" you write about above (initiating a game, etc) are not a part of the Transport Layer API. TransportLayer does what the TransportLayer does and that is it.

    Also when you write "AddHost prepares your app to accept said connections."... this is what we call "bind" in standard client server programming in C, PHP, etc. Sockets are created (Create). Then they are bound to the application (Bind). Create, Bind. After a socket is created and bound to the code we are writing (the app), then it can be configured to read and write to the socket, and this is lower level stuff, not high level (HLAPI), kinda stuff I am talking about.

    Initializing a game, etc. is a HLAPI (or many UnityEngine.Networking) function, not a lower level TransportLayer function.

    There is nothing in the LLAPI (TLAPI) Unity docs which describes anything more basic than a subset of low level transport layer protocols, described in a way which is not consistent with client / server programming. In fact, if you search the net, most coders say the same exact thing, so they (correctly) name their Unity LLAPI variable which creates and binds the socket "createSocket" or something similar because they also realize that "AddHost" is not correct at the LLAPI (TLAPI) level. LOL

    Anyway, sorry to get off topic, as this a PUN place, not a Unity LLAPI (TLAPI) place.

    Peace.
     
  8. neounix

    neounix

    Joined:
    Jan 9, 2017
    Posts:
    28
    Also, just to be complete (see above rant, LOL), here is an email message I sent to a top Unity Asset coder (name not mentioned):


    Who then replied to me as follows:

    LOL

    I have not meet anyone who thinks the Unity Network (the APIs) is / are well done; especially the top coders I know! Googling around on the net, I'm hard pressed to find anyone singing the praises of how Unity does their networking code.

    ... and I am well experienced in client / server applications, and I can't get Unity LLAPI to work except when the client and server are on the same machine.... hey! it's not that hard to change an IP address, but it does not work as it should, LOL ++++
     
    Last edited: May 5, 2018
  9. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    HEy. I was gonna download latest version and noticed that 4.7.2 is no longer supported. I understand perfectly.

    Still I remember seeing a version supporting 4.7.2 that had the additional servers aded some time ago.

    So. What is the latest 4.7.2 supporting version? how do I get it?
     
  10. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,068
    Yes, we dropped support for 4.7.2 recently, as even 5.x is no longer updated by Unity.
    What do you mean by "had the additional servers"?
    As the Asset Store has no feature to download older versions, you have to mail us, to get an older version. Or download with a newer Unity version and move things to 4.7.2 manually...
     
  11. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    I remember some extra servers where added at some point as USA was splitted in two servers East/West and some new server locations added like Korea etc...

    I'll send you a mail here:
    developer@photonengine.com
    With the invoice. Sorry for giving extra work. Just whant to update to the max.

    (edit: email sent)
     
    Last edited: May 14, 2018
  12. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    Neverming I've 1.88 from april 10 on the store!. I just recalled that it was interferring with Json.net and I downloaded a fresh version to the store at that point. It was using Json.net for editor serialization but I was using it for runtime serialization and I remember it giving me issues. Its not this exact project but a fork I made of it but whatever what is important is that I've quite recent version. Gonna write for not to provide a download link.

    Not being able to download older versions is something that is a no good of this store.

    edit:
    Ok, release notes apply to new version not current version, whatever. 1.88 is like not too far from now.
     
    Last edited: May 15, 2018
  13. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,068
    It's good to know that you could update to v1.88 at least. That's reasonably up to date.
    If you wanted to, you could download v1.90 and merge the changes over to your project. Especially the update for the "Best Region" feature would be nice to have. Aside from that, you should be fine with v1.88.

    Thanks for staying up to date :)
     
  14. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,068
    Minor heads up:
    There's one incompatibility with the PhotonEditor in Unity 2018.2. The relevant code about the RPC-attribute can safely be commented out and the rest will work. We will update PUN accordingly, of course (but next week).
     
  15. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    Hi @tobiass I am using Photon PUN to set up my game, for online, networking play but have a quick, but probably fundamental question.

    Looking at Online & Offline game play, knowing that Photon.PunBehavior (I bevlieve) inherits from (or vice versa), Mono Behaviour. Will I need to set up a scene, for offline game play, using MonoBehavior, and then one for online with PunBehavior, or can both exist in one scene, both using Photon.PunBehavior, just that any scripts will recognize that is is off or online?

    Also, what is the best way to ask, at function x(), if(AreWeOnline)?


    Thanks!
     
    Last edited: May 23, 2018
  16. IsntCo

    IsntCo

    Joined:
    Apr 12, 2014
    Posts:
    146
    I've spent a week banging my head trying to figure out what the problem is. Every time I thought I isolated it to particular code and fixed it, it would freeze. This led me to believe it was something overall with Photon/PUN.

    Here is a video example: https://screencast-o-matic.com/watch/cFhZoKbmKF

    What happens: I run two client executables of the game. One client creates the room, the other client joins it. The first two times I do this, it runs perfectly. Each time I exit out of the builds. The third time, the client that created the room locks up and crashes the build.

    There is no flow for reproduction. Sometimes its the second time I run the build. Sometimes the first. Sometimes the third. But at some point, the creator build always locks up. Same thing happens whether I'm in the Unity editor or a compiled build. I can barely even playtest my game because the Unity editor freezes constantly.

    I tried a Disconnect() when the Application quits, in case it was some cleanup issue, but that doesn't help.

    Build with: Unity 2017.3.1f1 PUN version: 1.90 (currently using the Free version from the Asset Store until I release the game)

    Link to download the compiled build if that helps: https://drive.google.com/file/d/1b3gYdFBizq_JmsfcUcfPtjNGnw-JxdJC/view?usp=sharing

    Help would be greatly appreciated! I'm not sure what is left for me to do to try and debug this.
     
  17. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    You don't need to do that. You can just use off line mode, but you will need to handle the fact that there are no other players.

    PhotonNetwork.connected should do that for you. But it will also return true if you are specifically in offline mode.
     
  18. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    I have just tried this with my game and cannot reproduce your problem. I can only see 2 things that were slightly different when I tried :
    1. The turnaround time for my game (to close it, start it, get through the menus and start the game play) is a little longer than yours.
    2. I used different room names each time. The way I handle the game play and, in particular, dropped connection handling means that I keep the room open for a period of time but disallow new entrants.
    Have you tried following the same sequence again but giving different room names each time? Maybe you happen to join a previous room instance at the moment that it is being destroyed on the server?
     
  19. IsntCo

    IsntCo

    Joined:
    Apr 12, 2014
    Posts:
    146
    Tried a longer room name and made sure to create different room names, froze like usual on the second try :/
    Really a frustrating bug - I can't figure any logic on my own that would cause this.
     
  20. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    Hi guys,
    I am building out a desktop version, and running a version from my editor of the game play.... I am able to load into the Lobby (or Launcher scene) on each. And at least the second build, to enter the Launcher scene, raises the room's player count to 2, at that point I am (believe I am) following along with the tutorial correctly, am using PhotonNework.LoadLevel("x");


    What happens next is the second player to enter the room, on whose Launcher script sees that since 2 players are in the room, we can load the appropriate game play level, however, it is only loading this new level on the 2nd player.

    Any thoughts?

    Code (csharp):
    1.  
    2.    
    3.         //this value is assigned when entered room, if 0 or 1 player already exists.
    4.         //it will define if player is on left or right of screen to start.
    5.         public override void OnJoinedRoom()
    6.         {
    7.  
    8.             Debug.Log ("Player has joined room, with curent player count = " + PhotonNetwork.room.PlayerCount);
    9.  
    10.  
    11.             int playerCount = PhotonNetwork.room.PlayerCount;
    12.             // #Critical: We only load if we are the first player, else we rely on  PhotonNetwork.automaticallySyncScene to sync our instance scene.
    13.             if (playerCount == 1) {
    14.                 //cache player as int
    15.                 Loading_Mng.playerAsInt = 1;
    16.             } else if (playerCount == 2) {
    17.                 //cache player as int
    18.                 Loading_Mng.playerAsInt = 2;
    19.                 ///here we must load the player selecition scene
    20.                 PhotonNetwork.LoadLevel("[3]PlayerSelection");
    21.             }
    22.  
    23.         }
    24.  
     
  21. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    Hi Guys,
    Just wondering and perhaps my logic is wrong or un-needed, but using PhotonView.RPC(), does this only fire on an object that was Instantiated over the network?
    Let me give you an example...


    If player A loads level X, where object Z has a PhotonView component. Object Z was not instantiated over the network, it simply placed in scene, before run, via the editor....

    If object X calls its photonView to photonView.RPC()... will the object X on player 2, somewhere else on the network, be called? Or must the relation have the instantiation factor as true.
     
  22. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    Another question.


    For my player controls I am using a series of scripts. Each script watches for a control pattern made by the user ex. A+B+B+A (with in a short time frame). If this condition is met, it fires this move (think Street Fighter) to the player animation etc.


    What I am wondering is, given that I have a high number of these sub managers, which watch to see if the controller input matches their custom requirements, and then fires if so... should each of these have a photonView attached, or should I have a single photonView attached to the player, and each of these subManagers is an Observable Component to the photonView of the player?


    I am thinking the latter, but I am just making sure my logic is correct.

    Thank you!
     
  23. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    Hmmm. I am wondering if trying to cut out as much code as possible from your project could help to see if something outside the networking code could be causing this somehow....? However, that does feel slightly unlikely.

    Given that I could not reproduce it though, do you think that you are handling all possible Photon events in your network handling code? Maybe Photon is sending a negative response that is not being detected?
     
  24. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    Objects that are part of the scene will receive Photon RPC calls as long as they have a PhotonView component. Also, bear in mind that the master client owns the scene view objects so must be the one to make the call (I can't find a text tutorial for this but there is this helpful video).

    You really want to limit your network traffic as much as possible. I would think to have just a single PhotonView on the player. When the owner detects a particular key combo, send an RPC to a method on that object that triggers the animation. That way, for that player's character, the animation will trigger on all connected clients.
     
    renman3000 likes this.
  25. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
  26. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    There are 2 ways to load a new scene in Photon :
    1. The master client calls LoadLevel whilst PhotonNetwork.automaticallySyncScene is set to true.
    2. All clients individually load the same scene (using the Unity API not the Photon API). When their scene is loaded, they will RPC to the master client. The master client will need to control the transition into the new scene, possibly by waiting for the RPC to arrive from all expected clients before continuing.
    When I was learning Photon, I went through this chap's course. Whilst I did not directly use his code, it was very helpful to understand the general architecture and process flow. Each episode is fairly short and easy to follow. You may be interested specifically in episode 6 where he talks you through a couple of ways of transitioning levels. :)
     
    tobiass and renman3000 like this.
  27. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697

    Sweet!
    Will be diving into tomorrow!
     
  28. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    Hi, thanks for all the help.
    I have run into a situation that I am unsure how to solve.

    a. When enter lobby, OnJoinedRoom() if player count is at max players, load level via master client, across all clients. Check.
    b. However, if one client leaves the game scene. But, another player enters the Lobby, this player instantly sees that the player count is now (including this player), at the max player number. So he joins the game, when in fact he should not.

    *Note: This was discovered when I was running a standalone and the editor. I closed the play on the editor, but had left the standalone open. So, when I re ran the editor, it automatically joined (which it should not).

    So I need to (if one player leaves game), close game?

    I hope that makes sense!
     
  29. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    That is a decision you need to make. You can lock rooms and (separately) make them invisible to prevent people joining.

    So you can either prevent people joining at an inconvenient time, or you could kick everyone out of the room if one person leaves. It's really up to what makes sense for your game.

    But I think that aspect is covered in the episode 6 I mentioned earlier. :)
     
    renman3000 likes this.
  30. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
  31. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    This is referring to blocks of data that are sent over the network. Generally, you want to keep this as small as possible. It is typically the slowest part of any networked game.
     
    tobiass likes this.
  32. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    So a group of info?



    Also, Correct me if I am wrong in my thinking, but I thought this.....
    if, object X has a PhotonView Component.
    if, this photonView is observing component Y.
    if, component Y is using OnPhotonSerializationView,
    that this function will act in a sense like an Update()?

    My issue is that on component Y, I do not appear to be getting any info, the function is not firing?
     
  33. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    Have you confirmed that, on the owner, the call is being made to serialize the data into the stream?
     
  34. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    Hi thanks,
    I believe the issue was that I was using "OnPhotonSerializationView()"... for some reason. Not, "OnPhotonSerializeView()"....


    Thanks!
     
  35. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    Yes, that would be a problem. Glad you got it sorted. :)
     
    renman3000 likes this.
  36. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    Thanks.

    Getting the hang of it.
    I have my launcher, into player selection, into game scene working, but there a few kinks at enter game scene, just from my end.

    Cheers
     
    tobiass likes this.
  37. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    Hi Guys,
    This may be very low on information but I have a call...
    Code (csharp):
    1.  
    2. photonView.RPC("psn_setPlayerIcons", PhotonTargets.AllViaServer, 1);
    3.  
    .. that at current time only seems to fire to all clients, if this is the MasterClient. I have no restrictions to check if this is originally called from the masterClient, or if this photonView is mine. It is a call each client needs to make, but at current stand point only the MasterClient has its related items fired upon.


    Any ideas?


    Code (csharp):
    1.  
    2.  
    3.  
    4.         if (gameMode == 3)
    5.         {
    6.  
    7.           //game mode 3 = online multi
    8.  
    9.  
    10.  
    11.   ////check local cached player, marked in Launcher as player who enters room 1st, 2nd.
    12.  
    13.             if (Loading_Mng.playerAsInt == 1){
    14.                 photonView.RPC("psn_setPlayerIcons", PhotonTargets.AllViaServer, 1);
    15.             }
    16.             if (Loading_Mng.playerAsInt == 2){
    17.                 photonView.RPC("psn_setPlayerIcons", PhotonTargets.AllViaServer, 2);
    18.             }
    19.         }
    20. [code]
    21.  
    22.  
    23. [code]
    24.  
    25.  
    26.     [PunRPC]
    27.     void psn_setPlayerIcons(int id)
    28.     {
    29.  
    30.         //sent via this (from local to local and client)
    31.         //initiates player icons.
    32.         playerSelection_Mngs[id].set_playerIcons();
    33.        
    34.  
    35.     }
    36.  
     
  38. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    The RPC will call to all connected clients *but* it will definitely go to the server first. The benefit of this is to control the sequence that all clients (including the caller) receive that call. If, for example, you used "All" as a target instead, then that would just resolve down to a method call on the local client. Meaning it would receive the call before all others, possibly including before the server.

    Now, one thing to bear in mind with non-buffered calls (such as AllViaServer), is that they will only work on connected clients. If your clients connect moments later, that RPC call is lost to them. Are you absolutely positive that all your clients are connected?
     
  39. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    Hey, I'm getting an odd error.

    I'm using 4.7. I updated recently to 1.88 (a versión I had downloaded).

    Whe I apply changes to prefab I get this error:
    upload_2018-5-30_0-9-54.png

    And when I try to enter gameplay I've a lot of spawning errors
    upload_2018-5-30_0-10-21.png

    May be that versión had some kind of bug?
     
  40. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    Ok I've restored the older photon and I'm getting sam eissue ! :\

    Could it be because I use my onw Json.net dll?

    restored newtonsofts dll and removed mines, aside of issues because my code can´t reach the dll anymore I still get same id warnings when applying changes to prefabs, now I feel defeated.
     
    Last edited: May 30, 2018
  41. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    Ok, FIXED!. In a very weirdo manner. I noticed that when selecting the tanks I was getting the warning message, but after that, If I did reselect a tank it didnt show, so I when trough all tank prefabs, and seemed like the editor scrip (view handler) managed to fix all the issues. Its weir anyway because when apply changes to the prefab I get same error. I guess I Will need to be very carefull from now on and after doing a master build go trough all prefabs.

    After redoing all prefabs, despite warning msg is shown there is no need to go trough all prefabs again. Seems like it has been fixed.
     
    Last edited: May 30, 2018
  42. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    EDIT: Solved.
    Can provide solution if wanted.



    --------original post---
    Ok,
    so I adjusted my code to simply call from the master client, to all targets..

    Code (csharp):
    1.  
    2.             if (PhotonNetwork.isMasterClient)
    3.             {
    4.                 photonView.RPC("psn_setPlayerIcons", PhotonTargets.All, 0);
    5.             }
    6.  
    However, it does not reach my client. Only the master.
    ??
     
    Last edited: May 30, 2018
  43. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    That code reaches all players and that RPC call is sent only by the master.
     
    renman3000 likes this.
  44. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    I know I will sound like an idiot for asking this but, my scenario. I have 2 objects, created in the editor, before run. They are identical in they use the same component X. They each also have a photon view. The idea is these objects each handle player selection, in a Street Fighter like game.


    That said, how do I insure that one of these object X, only talks to the object X associated with it, on the network. So, P1 only talks to P1. At the moment they either talk to all or none.

    I could use a custom Boolean but what is the native PUN condition I should use?
     
  45. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    I know this can be done, in fact I do that in my game but don´t remember sintax. I asked that time ago. @Kurtav answered me the solution. You can send an rpc to an specific view id.
     
    renman3000 likes this.
  46. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    No you won't, because networking is tricky (but please do read my last paragraph below in this comment). :)

    I'm a little confused there because, assuming I am understanding you correctly, you are describing the exact way that Photon is intended to work. That is why a (Photon) networked object has to have a PhotonView - to give each object its identity on the network. This identity is shared, for that specific object, on all connected clients.

    If you call,
    myPhotonObject.RPC( "RPC_MyMethod", <<xxx>> )
    , then this will call method
    RPC_MyMethod
    on all networked instances of
    myPhotonObject
    that are running on client <<xxx>>. Where <<xxx>> can be a group of clients as specified here, or on a specific client using, for example,
    myPhotonObject.owner
    .

    Again, I really, really would recommend that you go through the YouTube course I linked to above. :) Getting your head round this stuff is quite simply tricky. It is better to have someone guide you rather than try to figure it out by trial and error. Honestly, I appreciate it feels like a big drain on time but I assure you, it will pay dividends - you will get a fuller understanding much sooner that way. :)
     
    Munchy2007 and renman3000 like this.
  47. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697

    ok, I will go back over the tutorials... at the moment I am getting the master moves both P1 and P2 player selections (locally and remotely). However the client works as it should, only moving itself, locally and remotely.

    So something is clearly a miss!




    Just in case, I will post my code....
    Code (csharp):
    1.  
    2. ///where activeBtn_asInt, allows me to snap a cursor to the position of activeBtn_asInt (where this is in a local array).
    3.                 int[] package = new int[]{activeBtn_asInt, photonView.viewID};
    4.                 photonView.RPC("prn_MoveCursorTo", PhotonTargets.AllViaServer, package);
    5.  


    So that is my send, this is where I am puzzled, in my receiver...
    Code (csharp):
    1.  
    2.  
    3.     //Recieve
    4.     [PunRPC]
    5.     void prn_MoveCursorTo(int[] package)
    6.     {
    7.      
    8.         int n = package[0];//rank for cursor position snap in local array.
    9.         int viewID = package[1];//check if sent via associated photonView (P1 or P2)
    10.  
    11.  
    12.         if(viewID != photonView.viewID){
    13. ////since the local viewID (of this photonView), does not match that of sent, return.....
    14.             return;
    15.         }else{
    16.        
    17. //only a matching viewID sent, to this local viewID, should be here. However this is only true when sent from client.
    18. //...in case of Master, it sends to this, and to the other.
    19. //hmmmm..
    20.         }
    21.  
    //THANKS
     
  48. Tomza

    Tomza

    Joined:
    Aug 27, 2013
    Posts:
    596
    Hi,

    I create a room with the Master Client, and then I start the second instance of game as an ordinary Client and player is doubled (now, there are three players visible and the two are controlled by the Master Client).
     
    Last edited: May 31, 2018
  49. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    Hi Tomza,

    There are a great many possible ways that this could happen. Unfortunately, you have not presented nearly enough information to assist. :)

    However, before you paste a lot of code to further clarify your situation, could I just check- have you followed any tutorials (such as this one, it is very good and totally free)? Getting a networked project working correctly is inherently tricky. I would most strongly recommend getting a good understanding first if you haven't already done so. :)
     
  50. Tomza

    Tomza

    Joined:
    Aug 27, 2013
    Posts:
    596
    My tutorial is at the link:


    It works, but when I add my own player (animated character) plus I changed
    PhotonNetwork.automaticallySyncScene = false;
    to
    PhotonNetwork.automaticallySyncScene = true;

    because my second player was unable to join the created room.

    Now I'm watching:


    Please help me.