Search Unity

Third Party Photon Unity Networking

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

  1. Kurtav

    Kurtav

    Joined:
    May 24, 2015
    Posts:
    93
    Will not work. You can clear the entire stack of RPC calls from the player but not in parts
    Code (CSharp):
    1. PhotonNetwork.RemoveRPCs(PhotonPlayer targetPlayer)
    2. PhotonNetwork.RemoveRPCs(PhotonView targetPhotonView)
     
  2. JosephHK

    JosephHK

    Joined:
    Jan 28, 2015
    Posts:
    40
    Why don't photon pun provide us some options to make the server only remember the latest RPC?
    Remembering and sending all of them to the newly connected players is really bandwidth unfriendly which costs money actually.
     
  3. JosephHK

    JosephHK

    Joined:
    Jan 28, 2015
    Posts:
    40
    I also want to point out that the serialization in photon is also bandwidth unfriendly.

    For the primitive data types, one more byte of type info is needed.
    For custom types, many more bytes are needed. e.g. the Vector2 consisting of two float requires 12bytes.
    It is still understandable for the serializations of arguments of RPCs.
    But for the serializations using OnPhotonSerializeView(), additional bytes for the type infos are totally unnecessary at least when using unreliable observed option.

    So, Why don't provide us something like NetworkWriter and NetworkReader in UNET?
     
  4. Tarodev

    Tarodev

    Joined:
    Jul 30, 2015
    Posts:
    190
    Decided to try Photon today and have had trouble getting it up and running.

    I started a fresh project, downloaded the newest version of photon and imported it, immediately hit with this:
    Once I force it to use ExitGames.Client.Photon.Hashtable I then get hit with:
    and

    What have I done wrong and what can I do to fix it? :)


    EDIT: To fix this you can comment out the photon version of the scene manager (ensure you're using a recent version of unity). If you're using VS, right click -> go to definition -> choose the photon one -> comment out.
     
    Last edited: May 23, 2017
  5. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    Its not possible to cache only the latest RPCs, sorry. It's also not currently planned, even though it would be useful (I would like it too).
    Sorry.
    You can maybe use Custom Properties instead. Those have only the recent value.
     
  6. Bionicle_fanatic

    Bionicle_fanatic

    Joined:
    Jun 8, 2013
    Posts:
    368
    Toodles,

    Got this code: Make a build of it, runs fine and spits out the debug text properly.

    Code (csharp):
    1.  IEnumerator Start()
    2.     {
    3.         PhotonNetwork.autoJoinLobby = true;
    4.         PhotonNetwork.ConnectUsingSettings (Application.version);
    5.         while(PhotonNetwork.connecting)
    6.             yield return new WaitForFixedUpdate();
    7.         GameObject.Find("Debug").GetComponent<Text>().text += "\nConnected to server";
    8.     }
    9.  
    10.     void OnJoinedLobby()
    11.     {
    12.         GameObject.Find("Debug").GetComponent<Text>().text += "\nJoined lobby " + PhotonNetwork.lobby.Name;
    13.     }
    14.  
    15. //when clicked, joins a random room
    16.     public void Join()
    17.     {
    18.         PhotonNetwork.JoinRandomRoom();
    19.     }
    20.  
    21. //when clicked, create and join a room
    22.     public void Create()
    23.     {
    24.         PhotonNetwork.CreateRoom("Test");
    25.         GameObject.Find("Debug").GetComponent<Text>().text += "\ncreated room Test";
    26.     }
    27.      
    28.     void OnJoinedRoom()
    29.     {
    30.         GameObject.Find("Debug").GetComponent<Text>().text += "\njoined room " + PhotonNetwork.room.Name;
    31.     }
    32.  
    33.  
    I try and connect with the editor build, and it works fine. Then I attempt to Join a random room (meaning room "Test", as it's the only available room). This error pops up:

    Code (csharp):
    1.  
    2. Operation failed: OperationResponse 225: ReturnCode: 32760 (No match found). Parameters: {}
    3. UnityEngine.Debug:LogWarning(Object)
    4. NetworkingPeer:OnOperationResponse(OperationResponse) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1563)
    5. ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[])
    6. ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
    7. ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
    8. PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:157)
    9.  
    It's not the timing between the creation of the room and the attempt to join: I waited at least a full minute before trying it.
     
  7. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    Are you saying you are running this in 2 distinct clients and it fails? It looks OK.
    Have a look at the ConnectAndJoinRandom.cs code. It does what you want (too) and works fine for me for years.

    Edit: Is this the only code running at all?
     
  8. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    I can´t figure out how to send ans rpc to an specific player. I would like to use its owner.id to target an RPC.

    As the master client controls theh games kill counts etc.. the events such as doublé kills should be handed from the master client too and sent to each player... may be I should build stuff another way?
     
  9. Kurtav

    Kurtav

    Joined:
    May 24, 2015
    Posts:
    93
    Example - We send a RPC to a player whose ownerId is equal to two
    Code (CSharp):
    1. PhotonPlayer player = PhotonPlayer.Find(2);
    2. photonView.RPC("name_rpc_function", player );
    A couple more details:
    If a player enters his prefab, he gets the following values -
    PhotonNetwork.player.ID = photonView.ownerId
     
    Last edited: May 26, 2017
    TooManySugar likes this.
  10. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    Thank you soo much I thought the only option where to use photontargets. and use the preset ones.

    I'v still pending to ask you about the sync of tanks with your improved photon traffic package but I'm so dam busy with the game update that I want to focus in other stuff atm. I had networking stuff finished but adding audio events found myself in the need of updating some network stuff.
     
  11. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    We just released PUN v1.84! This version opens up support for more consoles, improves memory usage and avoids a potential freeze situation when no network is available.

    v1.84 (30. May 2017)
    Fixed: PlayerRoomIndexing can now be added at runtime even on non MasterClient instance. master player is now indicated in the inspector.
    Updated: NetworkingPeer.RunViewUpdate allocates less memory.
    Moved: ReorderableListResources to namespace Photon.Pun to avoid conflicts with other "Rotorz" variants. This is an internal Editor-only change.
    Updated: Unity 2017 Support.
    Added: Support for a Switch add-on. You need to be certified developer for the platform to get access for this. Contact us by mail: developer@photonengine.com
    Changed: SocketWebTcp to handle status changes for the used WebSocket. This fixes uncommon issues in WebGL exports.
    Changed: SocketUdp.cs to lock less parts of the DNS / connection setup, which avoids potential freezes.
    Updated: To Photon library v4.1.1.12 with various fixes. See plugins\release_history.txt.
     
  12. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
  13. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    @Shadowing: I replied to the post now. I don't know why my colleagues didn't pick it up. Usually, we try to help :)
     
  14. hoangphuc

    hoangphuc

    Joined:
    Mar 9, 2014
    Posts:
    2
    I made turn-based game, bandwith in game is so slow, but I want reach to 5000 CCU, so Do photon have plan for this case? I think pricing of Photon is expensive.
     
  15. dmoroni

    dmoroni

    Joined:
    Mar 10, 2015
    Posts:
    23
    Hi, I'm using Photon for a multiplayer VR game i'm developing and I would ask just a question.

    Until now I used the "Photon Cloud" hosting solution, while now I should switch to "Self Hosted". Apart from inserting the Server Address/Port in the Server Settings panel, should I do some other operation? Is there a server application i should install on my local server?

    Thanks,
    Riccardo
     
  16. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Why does Photon networking force you to use prefabs in a resource folder? Is that the only way to do it?
    That creates a large issue of having prefabs stored in memory that you are not using in the current scene.
     
  17. o0neza0o

    o0neza0o

    Joined:
    Sep 6, 2015
    Posts:
    165
    How would i go about using TS colliders to bounce other players into traps? and also how would i use the traps to kill other players using truesync? Another problem i'm finding is where i cannot understand how to develop a scoreboard for photon
     
  18. MichaelQN

    MichaelQN

    Joined:
    Apr 10, 2017
    Posts:
    6
    I am wanting to use Photon to create an Online RPG. (Same elements and gameplay of an MMO, just a smaller scale to learn about networking and how an MMO works.) Is it possible to use the Photon On Premise SDK to self host the servers, while also connecting with the unity client, or do I have to use PUN? If I have to use PUN, can I self host it? Or am I forced to use the photon cloud servers.
     
  19. alexisps

    alexisps

    Joined:
    Dec 2, 2014
    Posts:
    1
    Hello,
    I am using Photon free edition, i requested to upgrade Photon from Playfab and it is still saying (Max CCU of 20 reached).

    How to solve this?

    Thanks
     
  20. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    It might be an account issue. Playfab create Photon Apps for you. Afaik, you can't access those AppIds in our Dashboard, as they are generated for you. So maybe you just look at the wrong AppId (one that's not updated).
    In doubt, please ask PlayFab if they processed your request to upgrade.

    Yes, you can do that. It's actually the more elaborate way and opens more options to customize the server side.
    On the client side you can use the Photon Unity SDK from on our download page (or PUN, too).
    Be aware: When you modified the server side, you're locked in to hosting it, too. We don't offer hosting in our Cloud for fully customized server-code.

    This topic is about PUN, not True Sync. Please ask these questions in the True Sync forum:
    http://forum.photonengine.com/categories/photon-true-sync

    The resource folder option is just the simplest option.
    You can also do manual instantiation but I would suggest having a look at the PhotonNetwork.PrefabPool. That way, you can keep instances around or instantiate them any way you want, basically.

    Well, yes. You need a "self hosted" server to make use of that Self Hosted option. Get the Server SDK and read the Server Docs to get started.
     
  21. hermolenda

    hermolenda

    Joined:
    Apr 9, 2017
    Posts:
    11
    Helllo !
    I am working with pun on some project. It was working before i updated the system. After an update i cant see another player. Same issue is in punviking demo asset. Its working until you upgrade pun system. What changed? What should i change in my code?
     
  22. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    @hermolenda: No errors in the logs? Are you sure the players are in the same room?
    We had cases, where the prefabs needed to be "touched" or recreated. Make sure each prefab is observing the script of the prefab (so it can be instantiated into observing the script on the instance).
    Do the demos in the package work?
     
  23. kage88

    kage88

    Joined:
    Jun 21, 2017
    Posts:
    2
    Tobias :

    Get this exception when I trying connect to photon:
    TypeLoadException: Error verifying ExitGames.Client.Photon.EnetPeer:get_encryptor (): Could not load type ExitGames.Client.Photon.EncryptorManaged.Encryptor at 0x0000
    ExitGames.Client.Photon.EnetPeer.InitPeerBase ()
    ExitGames.Client.Photon.EnetPeer.Connect (System.String ipport, System.String appID, System.Object custom)
    ExitGames.Client.Photon.PhotonPeer.Connect (System.String serverAddress, System.String applicationName, System.Object custom)
    NetworkingPeer.ConnectToRegionMaster (CloudRegionCode region)
    PhotonNetwork.ConnectUsingSettings (System.String gameVersion)

    PUN v1.84.1
    Unity 5.3.4
    Web Player Build
     
  24. o0neza0o

    o0neza0o

    Joined:
    Sep 6, 2015
    Posts:
    165
    i get this error:
    PhotonView with ID 8002 has no method "AddMassProperty" marked with the [PunRPC](C#) or @PunRPC(JS) property! Args: String
     
  25. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    @o0neza0o: Read the message. Try to make sure that the method exists, got the attribute and a string as argument.

    @kage88: WebPlayer? Not WebGL, right? I wasn't aware the WebPlayer is still supported / used, so I think we didn't check it anymore. Try out, if the Stripping Level settings mage a difference for the build. Check the DotNet compatibility level makes a difference. We are pretty swamped with work and plan for Unite Europe, so we can't debug right away. Maybe next week.
     
  26. kage88

    kage88

    Joined:
    Jun 21, 2017
    Posts:
    2
    Last edited: Jun 23, 2017
  27. hermolenda

    hermolenda

    Joined:
    Apr 9, 2017
    Posts:
    11
    i got this:
    Received OnSerialization for view ID 1001. We have no such PhotonView! Ignored this if you're leaving a room. State: Joined
     
  28. Imperial_Man

    Imperial_Man

    Joined:
    Jun 24, 2017
    Posts:
    1
    Hello, I'm about Photon Server. I'm using Script which runned from multi threads (may run several instances in one time). But there are one variables for all threads. But I want to unique variables for every thread.
    e.g:
    Code (CSharp):
    1. public class Test
    2. {
    3.     int MyInt = 0;
    4.     void CallingVoid()
    5.     {
    6.         MyInt++;
    7.         Log.Info(MyInt);
    8.     }
    9. }
    10.  
    So if there will be 4 threads in one time it should write in Console
    "1" 4 times. Not 1,2,3,4!
     
  29. BrianND

    BrianND

    Joined:
    May 14, 2015
    Posts:
    82
    Photon has a MMO structure which implements areas of interest which filter network communication between players that are only near or visible to each other. This is probably what GTA does
     
    Syberam likes this.
  30. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    @Syberam: Having 1000 players connected to one Photon server is not a problem and there is plenty of CPU for your code to do interest management and more. The smart guys at Sandbox Interactive are running Albion Online on Photon.

    @Imperial_Man: That's not a networking/Photon question. Please check www.stackoverflow.com or similar.

    @hermolenda: Crank up the debug logging of PUN and run again. It's unclear if you never got the Instantiate call or if you dropped the object when loading, or if it's something entirely different. You might want to add Debug.Log to the prefab you instantiate (in Awake(), e.g.) to make sure it gets created. Make sure to use PhotonNetwork.Instantiate() to let others know what a network player instantiates (if you missed this, consider coding the basics tutorial once)...

    @kage88: For the time being, yes, an older version would be simpler. We can check the current build with the webplayer (which Unity has the latest?!) but we cannot put this on prio. Please mail us for, if you don't have an older version anymore.
     
    Syberam likes this.
  31. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    We just release a new PUN version:

    v1.85 (6. July 2017)
    Fixed: Interest Groups IDs are now of type byte for Instantiate (and all related code) as well. This fixes a cast exception.
    Fixed: Internal use of NetworkingPeer.IsInitialConnect. It's now reset when the connection fails while connecting. This (currently) affects the "connected" and "connecting" values, which is likely to change. This fix is minimal by design.
    Updated: PUN to no longer make use of obsolete enum values of the Photon library (dll).
    Updated: Chat API and ChatGui. Now uses a thread to call SendOutgoingCommands, which keeps connections up (except on WebGL, where threading is not available).
    Updated: To Photon library v4.1.1.14 with various fixes. See plugins\release_history.txt.
     
    Syberam likes this.
  32. kyubuns

    kyubuns

    Joined:
    Aug 6, 2013
    Posts:
    138
    Hi,
    I found crash bug in Unity2017.1.0f1 + iOS(IL2CPP)+ .net4.6. (PUN v1.85)
    Is this Unity's bug?

    * Success
    - Unity2017.1.0f1 + PC&Mac + .net3.5
    - Unity2017.1.0f1 + PC&Mac + .net4.6
    - Unity2017.1.0f1 + iOS + .net3.5

    Source code

    Code (CSharp):
    1. var roomOptions = new RoomOptions();
    2. roomOptions.MaxPlayers = 4;
    3. roomOptions.Plugins = new string[] { "PluginName" };
    4. roomOptions.CustomRoomProperties = new Hashtable { { "C0", "Room01" }, { "C1", "Matching" } };
    5. roomOptions.CustomRoomPropertiesForLobby = new string[] { "C0", "C1" };
    6.  
    7. var sqlLobby = new TypedLobby("GameLobby", LobbyType.SqlLobby);
    8. PhotonNetwork.CreateRoom(Guid.NewGuid().ToString(), roomOptions, sqlLobby);
    Error when crash on xcode

     
    Last edited: Jul 12, 2017
  33. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    A "Bad Access" exception? This looks more like an issue in Unity. Also, if it's working in other Unity versions, it's most likely a regression. Please report this to Unity. Check if changing some build options helps.
     
  34. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    I agree, this looks like something on the Unity side. @kyubuns, can you submit a bug report?
     
    tobiass likes this.
  35. kyubuns

    kyubuns

    Joined:
    Aug 6, 2013
    Posts:
    138
    OK!
    I send a bug report with the problem project.
    Case 930163
     
  36. wasifmac

    wasifmac

    Joined:
    Feb 4, 2017
    Posts:
    4
    Help!!!

    Here when i create a room from first person , room is created and when second person comes it joins the room, but when third person comes it creates new room ,while it should join the same room because the room have maxplayer =10.
    As there is joinrandomroom() function , So , i have tested multiple times but still third person creates new room.

    Unable to join same room for Third person In photon?

    void Start () {
    competePlayeScale = true;
    PhotonNetwork.JoinRandomRoom();
    // PhotonNetwork.JoinOrCreateRoom ("room_", new RoomOptions{ MaxPlayers = 10 }, TypedLobby.Default);
    spawnPoint = new Vector3[]
    {
    new Vector3 (-1.2f, -17.1f, 35.1f),
    new Vector3 (15f,-16.9f, 35.4f),
    new Vector3 (-15f,-16.9f, 35.4f),
    new Vector3 (-40, 0, 0),
    new Vector3 (-20, 0, 0),
    new Vector3 (0, 0, 0) ,
    new Vector3 (20, 0, 0),
    new Vector3 (40, 0, 0),
    new Vector3 (60, 0, 0),
    new Vector3 (80, 0, 0)
    };

    }

    void OnCreatedRoom() {

    }

    void OnPhotonRandomJoinFailed() {

    PhotonNetwork.CreateRoom (null, new RoomOptions{ MaxPlayers = 10 }, null);

    } void OnJoinedRoom() {

    if (PhotonNetwork.playerList.Length == 1) {

    MyPlayer = (GameObject)PhotonNetwork.Instantiate (prefabSamurai.name, spawnPoint[0],Quaternion.identity, 0);

    MyPlayer.transform.rotation = Quaternion.Euler (0f,180f, 0f);

    MyPlayer.transform.localScale = new Vector3 (15, 15, 15);

    }

    if (PhotonNetwork.playerList.Length == 2)

    {

    MyPlayer = (GameObject)PhotonNetwork.Instantiate (prefabSamurai.name, spawnPoint[1], Quaternion.identity, 0);

    MyPlayer.transform.rotation = Quaternion.Euler (0f,200f, 0f);

    MyPlayer.transform.localScale = new Vector3 (15, 15, 15);

    }

    if (PhotonNetwork.playerList.Length == 3)

    {

    MyPlayer = (GameObject)PhotonNetwork.Instantiate (prefabSamurai.name, spawnPoint[2], Quaternion.identity, 0);

    MyPlayer.transform.rotation = Quaternion.Euler (0, 200, 0);

    MyPlayer.transform.localScale = new Vector3 (15, 15, 15);

    } }
     
  37. wasifmac

    wasifmac

    Joined:
    Feb 4, 2017
    Posts:
    4
    Unable to join same room for Third player In photon?

    Here when i create a room from first person , room is created and when second person comes it joins the room, but when third person comes it creates new room ,while it should join the same room because the room have maxplayer =10.

    As there is joinrandomroom() function , So , i have tested multiple times but still third person creates new room.

    void Start () {
    competePlayeScale = true;
    PhotonNetwork.JoinRandomRoom();
    // PhotonNetwork.JoinOrCreateRoom ("room_", new RoomOptions{ MaxPlayers = 10 }, TypedLobby.Default);
    spawnPoint = new Vector3[]
    {
    new Vector3 (-1.2f, -17.1f, 35.1f),
    new Vector3 (15f,-16.9f, 35.4f),
    new Vector3 (-15f,-16.9f, 35.4f),
    new Vector3 (-40, 0, 0),
    new Vector3 (-20, 0, 0),
    new Vector3 (0, 0, 0) ,
    new Vector3 (20, 0, 0),
    new Vector3 (40, 0, 0),
    new Vector3 (60, 0, 0),
    new Vector3 (80, 0, 0)
    };

    }


    void OnCreatedRoom() {

    }

    void OnPhotonRandomJoinFailed() {

    PhotonNetwork.CreateRoom (null, new RoomOptions{ MaxPlayers = 10 }, null);

    } void OnJoinedRoom() {

    if (PhotonNetwork.playerList.Length == 1) {

    MyPlayer = (GameObject)PhotonNetwork.Instantiate (prefabSamurai.name, spawnPoint[0],Quaternion.identity, 0);

    MyPlayer.transform.rotation = Quaternion.Euler (0f,180f, 0f);

    MyPlayer.transform.localScale = new Vector3 (15, 15, 15);

    }

    if (PhotonNetwork.playerList.Length == 2)

    {

    MyPlayer = (GameObject)PhotonNetwork.Instantiate (prefabSamurai.name, spawnPoint[1], Quaternion.identity, 0);

    MyPlayer.transform.rotation = Quaternion.Euler (0f,200f, 0f);

    MyPlayer.transform.localScale = new Vector3 (15, 15, 15);

    }

    if (PhotonNetwork.playerList.Length == 3)

    {

    MyPlayer = (GameObject)PhotonNetwork.Instantiate (prefabSamurai.name, spawnPoint[2], Quaternion.identity, 0);

    MyPlayer.transform.rotation = Quaternion.Euler (0, 200, 0);

    MyPlayer.transform.localScale = new Vector3 (15, 15, 15);

    } }
     
  38. piginhat

    piginhat

    Joined:
    Feb 17, 2016
    Posts:
    96
    HI, I'm new to PUN and am working through the basic tutorial and so far all makes sense apart from the section on Health Setup where I seem to have a mental block on the use of PhotonView.isMine.

    Code (csharp):
    1.  
    2. void OnTriggerEnter(Collider other) {
    3.  
    4.     if (! photonView.isMine) {
    5.         return;
    6.     }
    7.  
    8.     if (!other.name.Contains("Beam")) {
    9.         return;
    10.     }
    11.  
    12.     Health -= 0.1f;
    13. }
    14.  
    The comment for this method states:
    // Note: when jumping and firing at the same, you'll find that the player's own beam intersects with itself
    // one could move the collider further away to prevent this or check if the beam belongs to the player

    Which makes sense so I would expect the test to be:

    Code (csharp):
    1.  
    2.     if (photonView.isMine) {
    3.         return;
    4.     }
    5.  
    so here isMine if true meaning is mine (the client) return

    Have I missed this concept completely?....I think I have!
     
    Last edited: Jul 14, 2017
  39. SiliconDroid

    SiliconDroid

    Joined:
    Feb 20, 2017
    Posts:
    302
    @piginhat:

    photonView.isMine operates exactly as you state: true if the view is related to the local client.

    I'm guessing that demo is doing remote client side hit detection, i.e.: hits are only recognized when remote avatar beams hit local avatar which decrements its health variable whose value is then propogated via PUN. All the decision logic happens on the local client avatar only.

    I'm guessing that comment is not talking about a network related issue, it's a problem whereby a local clients beam can on occasion hit the local client avatar and the function will accept it as valid hit.

    There are many ways of doing hit detection in a distributed client manner (with no auth server), some of them are real head benders.
     
    Last edited: Jul 15, 2017
  40. piginhat

    piginhat

    Joined:
    Feb 17, 2016
    Posts:
    96
    Thanks for explaining and yes a real head bender, stuff like this hurts my head lol. I keep looking at that code block and try to digest your explanation but the ole head just ... blanks on me :-(
     
  41. SiliconDroid

    SiliconDroid

    Joined:
    Feb 20, 2017
    Posts:
    302
    In a multiplayer scene you've generally got 1 local avatar ( avL ) and N remote avatars ( avR[0 ... N-1] ).

    So the simplest way to handle damage is to do *one* of the below:

    Option 1: Check on local players machine
    When any avR[x] fires: does the bullet hit avL? (This is what your quoted sample does).

    Option 2: Check on remote players machine/s

    When avL fires: does the bullet hit any avR[x]?

    You can go more complex than the above 2 examples and gain fairness (harder to cheat) at the expense of more bandwidth.

    Fairest scheme involves checking all bullet/avatar instances (in all game processes) and then democratically deciding the "truth". So yeah, now I've mentioned that, maybe the simpler options have become more comprehensible.
     
    Last edited: Jul 18, 2017
    tobiass likes this.
  42. Kurtav

    Kurtav

    Joined:
    May 24, 2015
    Posts:
    93
    Question on photon instances
    I create my project and create a Resources folder and spawn an object called "Player". But the same name is in the folder Photon Unity Networking - Demos - DemoWorker - Resources(Second Resources folder in one project) - prefab worker with a wrench .
    What is the priority? Who is chosen from two identical names?
     
  43. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    Actually, I never figured out which resource is chosen, when the name is not unique.
    You should either make resources unique (and not import all demos into a proper project) or figure out what Unity's API makes out of loading resources which are not unique.
    You can also use a object pool.
     
  44. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    We're updating PUN in our project after upgrading to 2017.1 (and having crashes and runtime), but I get a bunch of errors:

    Assets/Plugins/Editor/Photon Unity Networking/Editor/PhotonNetwork/AccountService.cs(218,17): error CS0103: The name `PhotonEditorUtils' does not exist in the current context

    Assets/Plugins/Editor/Photon Unity Networking/Editor/PhotonNetwork/PhotonEditor.cs(483,164): error CS0619: `UnityEditor.BuildTarget.iPhone' is obsolete: `Use iOS instead (UnityUpgradable) -> iOS'

    What should we do?

    thx
    Dave
     
    MrLucid72 likes this.
  45. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    Did you upgrade PUN, too? The latest build should be 2017-compatible.
    The "UnityUpgradable" issues can be solved by letting Unity do an upgrade of the project. There should be a menu item for that, if Unity didn't open a dialog when you upgraded the project.
     
  46. JRRReynolds

    JRRReynolds

    Joined:
    Oct 29, 2014
    Posts:
    192
    @tobiass In the previous version of PUN+ there were instances when the master disconnected and a new client became master, then another client connected the client could not see the new master but the new master could see the client. Thankfully, this was fixed in 1.85. I am just curious, because this was a pretty substantial bug, was there anything in the new release that could have effected this. I went through release notes but the only thing I found that could have been related was: Internal: GameEnteredOnGameServer() first sets the local player's actorNumber, then updates the player lists.

    I am interested in knowing in case this bug pops up again, I can provide reference to something that may have changed with the internal code.
     
  47. R1PFake

    R1PFake

    Joined:
    Aug 7, 2015
    Posts:
    542
    Question about SetCustomProperties of the Room, the method wants a Hashtable (which is derived from a Dictionary<object, object>)
    But the method calls propertiesToSet.StripToStringKeys() which creates a new hashtable and ignores all values where the key is not a string and copies the other values.
    My question is if the method only wants string as a key, then why not just let me pass a dictionary of type <string, object> (or a custom hashtable where the key must be a string) then it wouldn't be needed anymore to create a new hashtable and copy/filter all values with a string key (which is a waste of time and memory in my opinion)

    (I know this is only a "small" thing it will most likely not matter for most games, but these "small" things can add up...)
     
  48. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    @Zrexa: You mean in v1.84, there was that bug? I am not sure what caused it (I think it wasn't me doing the repro for this). If the new client could not "see" the master, then it could be related to GameEnteredOnGameServer(), yes.

    @R1PFake: I have to agree that it's wasteful but the idea is that the Properties can contain string and byte keys. While the byte keys are reserved for Photon internal use (well known properties), the string keys are "Custom Properties". No matter what you do, the keys don't clash. So, we actually mean to use a Hashtable here (it's derived from a Dictionary, because the Hashtable class is not in the Windows Store APIs).

    So, it's complicated.
    Yes, we could have an overload with Dict<string, object> to set props. I'm not sure if this would be confusing or not.

    Probably the simpler solution is to add a check if non-string keys are in the Hashtable you provide and to avoid the copying, if that's not the case.
     
    R1PFake likes this.
  49. JRRReynolds

    JRRReynolds

    Joined:
    Oct 29, 2014
    Posts:
    192
    @tobiass
    Yes it had something to due with the warning: Received OnSerialization for view ID (AnyNumber). We have no such PhotonView! Ignored this if you're leaving a room. State: Joined

    I searched through the photon forums and saw that others had the same problem but it was never fully resolved and it only seemed to be brought up once every year or so. I feel like it had something to do with que'd message but I wasn't able to solve the problem. Since I updated to the new PUN it stopped happening most of the time.

    Previously it would happen when the master disconnected and then rejoined as a non-master. However, after the upgrade it only occurs (about 25% of the time) when 2 players try to join the room at the same time. The master can see the client but the client cannot see the master. I would be very interested to hear if your take on what might have changed if you have any ideas because like I said it is still happening.
     
  50. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    I looked at PrefabPool. But this requires the use of prefabs being in a resource folder?
    Code (csharp):
    1. PhotonNetwork.PrefabPool.Instantiate
    The reason I don't want to use a resource folder is cause I don't want to load enemies into a scene that isn't currently for that scene.

    So i'll have to make my own pool then with Manual instantiate
    https://doc.photonengine.com/en-us/pun/current/manuals-and-demos/instantiation

    Idk is it possible to take a list of prefabs and load them into resources so that resource string look up works? I'm gonna see if Unity has something like that.

    Maybe I'm wrong as to how resources work. Does everything in all resource folders get loaded into memory when a scene loads? Even before you do any instantiating from resources?

    Even if it doesn't load all resources into memory. What if I have 50 prefabs for 50 different scenes. That's 2500 objects that resources has to search through when instantiating from resources. Unless photon networking.instantiate supports resources relative link for it's resource string agrument?

    Sorry for having a few questions @tobiass . Really need answers to this. Getting pretty deep into my project now
     
    Last edited: Aug 7, 2017