Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Third Party Photon Unity Networking

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

  1. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    Yes, exactly.
    The next update for PUN Free and PUN+ will be virtually the same, except that PUN+ has different plugins.
    Right now, when you switch, you have replace all PUN Free files with those from PUN+. The Unity importer might fail (because filenames and paths are identical) but I can explain how to replace it manually if you should switch before PUN v1.25 is out. It's not too complicated.
     
  2. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    let me explain...
    i have 3 rooms and a room list that Shows [RoonName , RoomMap , RoomMode , countPlayers/maxPlayers , totalPing]

    i have done all the others but when it comes to totalPing i cant do it...
    totalPing: ping of all players / countPlayers
     
  3. AuroJj

    AuroJj

    Joined:
    Dec 13, 2013
    Posts:
    7
    Thank you very much for your answer!
    about whether I can put the name and chat line above the avatar's head (for example), I did not understand. (I put this as item 3)
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    Imho, you shouldn't worry about the average ping in a room. Averaging the ping first, then enabling others to avoid that game is not solving the problem. The player with bad ping won't be able to play nicely. If you think some ping is too bad to play, then make the client quit or choose another region. Ping with Photon also doesn't have the same meaning as in Half Life or other self-hosted games: You can't pick a host that has low ping in Photon but always connect to some dedicated server.

    Anyhow. You could make TotalPing yet another property of the room and have it updated to the lobby. Then, each player has to send the ping every now and then, while one client (the Master Client) can update the "TotalPing" property of the room.

    One more note: Any string that's send via the net should be as short as possible. This saves bandwidth and improves overall service quality.
     
  5. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    Yes you can. Of course!
    You can send RPCs to send the chat messages. On the receiving end, we call the RPC and pass a MessageInfo about who sent it. This includes the PhotonPlayer object and that has the name. Showing that is just a general Unity task. Maybe a 3d Text object is fine but then again: This scales down to "unreadable" when the user is in the background. I can't help with the display task really though.
     
  6. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    Hi,
    I don't understand, if the plus version include a lifetime subscription for 100 ccu, what's the point of the monthly subscription on the website?
    If somebody want to test it they have the 20ccu version, and if they already have the users they would just buy the plugin. Is there any advantage for the monthly version?
     
    Last edited: Dec 19, 2013
  7. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    00christian00: It gives you +100 CCU for one app permanently. If that's fitting your use case exactly is up to you. For example, you could invite some more test users even months before release. In the end, it should always be good to have a few more CCU for next to nothing, no matter how big your game is.
     
  8. AuroJj

    AuroJj

    Joined:
    Dec 13, 2013
    Posts:
    7
    Thank you, again, tobiass!
    ufff, I'm tired, I can not find information. Can anyone explain me, please, how do I get each player (client) see his own character?
    What happens is that if masterclient, enters the room instantiating playerprefab, and another player enters in same room instantiating myprefab works playerprefab for all who are in the room. I want everyone to have their own prefab. Can I do this?
     
  9. TobiasW

    TobiasW

    Joined:
    Jun 18, 2011
    Posts:
    91
    I have a question about PUN vs. on-premise/redistributable: It seems that those are two different client SDKs - one downloaded from the Asset Store, the other from your website. Is it possible to switch between both later without much effort? Do they share the same API?

    (And by the way: I guess I understand why the redistributable needs an internet connection on start up, but it's still a pity it's not useable in a no-internet scenario.)
     
    Last edited: Dec 22, 2013
  10. Magison

    Magison

    Joined:
    Mar 1, 2013
    Posts:
    21
    Hello AuroJj,
    i sounds you want the masterclient to networkInstantiate all players (when they spawn) and then reference them to a GameObject which the new Player has network-instantiated, so that the masterclient has full control over the player, but you do not loose the "real" owner of the player-character. The player hits a key (move forward), Masterclient receive this and move the character and send new position to all clients and the player itself back. I am right so far?
    I done this some time ago with the Unity Network. If a player connect and instantiate his "ghost", the masterclient/server set his name to the IP adress to store any information about the "real" owner. Then this player-object is set as child to the player-object instantiated by the masterclient. The player-script now read the name of his child (which is the IP) and know the owner or sender if everything happens.

    But i think it is not the correct way to solve such a situation professionel.
    I´m a newbie in networking. I think it is the best if the owner instantiate his own objects and not instantiate two objects for the same thing from differnt clients.

    Alex
     
  11. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    The Redistributable Server package (from our download page) is pretty much compatible with the Photon Cloud and can be used as alternative for LAN games. You keep the same client logic but switch it to another server.
    The redistributable is currently not having these features (avoid them and you should be fine):
    - You can't use "Game Version" values to separate your users based on features.
    - The server SDK doesn't have "Friend Finding".

    I agree that it's sad we don't support no-internet scenarios at the moment. As so often, it's a matter of checking the license :(
     
  12. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    You can check out the Marco Polo Tutorial. It doesn't do much but this :)
    http://doc.exitgames.com/photon-cloud/Marco_Polo_Tutorial

    You basically have each client instantiate it's own prefab and control it. You have to make sure that the scripts on said prefab are only active for the locally instantiated prefab / character. In the Marco Polo Tutorial, I disabled the control scripts on the prefab and ENABLED them for the singe instance we locally instantiated (the one returned by PhotonNetwork.Instantiate()).
     
  13. Dosetsu

    Dosetsu

    Joined:
    Dec 22, 2011
    Posts:
    39
    Just want to chime in here for the need to have a windows store app friendly release.

    Here is the current error when trying to build.

    Assets\Photon Unity Networking\Plugins\PhotonNetwork\SocketUdp.cs(17,22): error CS0234: The type or namespace name 'Sockets' does not exist in the namespace 'System.Net' (are you missing an assembly reference?)
     
  14. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    PUN Free should compile for the Windows Store but PUN+ doesn't at the moment. It's a bit tricky getting Unity to compile the needed plugins into each platform (skipping those which are not available).
    Maybe it works already if you wrap SocketUdp.cs in #if !UNITY_METRO compile conditions. Not entirely sure.

    In any case: Getting this to work out of the box is on the list for the next PUN (Free and Plus) update.
     
  15. Lumos

    Lumos

    Joined:
    Feb 11, 2013
    Posts:
    49
    Greetings. I've got some questions related to Photon in Unity, and I am very sorry if they've already been answered; however, I've not found the answers.
    In any case:
    - Photon seems like a good idea, but I need my users to host their own servers for LAN play, or to connect directly to one another with an IP address, a mechanic seen in games like Minecraft or - more recently - Starbound, for an example. Therefore, whilst the enbedded master server functionality would be very good for me to host all "public" servers (flagged as such by their creators), is Photon going to allow my users to create their own private games?
    - If the answer to the Q above is "yes", then would the "private" players count towards the limited CCU amount?

    Thanks in advance.
     
  16. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    Lumos:
    We have a "Redistributable Server" package on our download page. This can be licensed and customized to for dedicated private servers. The requirements are: the DotNet Runtime and internet access on a Windows machine.
    The private server don't count as Photon Cloud CCUs. They have their own 50 CCU count per instance and while up to 100 of self-hosted servers are free, there is a one-time fee for the next 500 (and more).
     
  17. Parappa

    Parappa

    Joined:
    Jan 27, 2013
    Posts:
    77
    Spawn question
    4 Players max, how do I give a player a spawn point they can go to back to at the beginning of every round?
    Keep in mind a player can leave and a new player can join at any time

     
    Last edited: Jan 10, 2014
  18. AuroJj

    AuroJj

    Joined:
    Dec 13, 2013
    Posts:
    7
    Magison, Tobiass, thank you both for your answers! :D
    I have a questions, please: How I can add chat messages, of each player, over the head of his avatar? I know to use GuiText and add it to my avatar, but what is the code that I need ?
     
  19. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    In Photon, you could use custom properties to store which player has which spawn point. You can save that list in the room properties or per player in the player properties (Player.SetCustomProperties).
    Checking the properties of everyone else in the room, each player can pick a spawn point when joining (implement OnJoinedRoom()).
    If more than one player joins at about the same time, you have to keep them from picking the same by accident. They each don't know which the other will pick. Each player has an ID (actor number) in a room, so you could make one player wait until anyone with a lower ID has picked a spawn point. You could implement OnPhotonPlayerPropertiesChanged(PhotonPlayer player) to get a callback when any user's properties changed.

    AuroJj:
    Find out how you place any objects in relation to each other or how to show text above some GO. Then replace that text with the chat messages. I think you will find help for this in the answers page.
     
  20. sk8terboy4

    sk8terboy4

    Joined:
    Mar 29, 2013
    Posts:
    29
    Im trying to convert a voxel game into multiplayer. I got to the point where a player start a server or join and the player will spawn in the game using a playerprefab. Whenever I try to use 2 players in one server, both players can not move and they are "teleported" to random areas like floating in air also the camera is locked in place. The voxel game is generating terrain. I dont know if that is the problem; I think everytime a player joins the server the terrain is generated twice. Would I have to make the terrainGenerator script that generates the terrain only for the host? if so how.
     
  21. sk8terboy4

    sk8terboy4

    Joined:
    Mar 29, 2013
    Posts:
    29
    Also I would like to know how to render certain objects in photon view. I am trying to make a FPS game. So the player camera will render the gun and arms but when looking at another player, it renders a different object like a 3rd person model and will not render the other player arms and gun and vice versa
     
  22. games

    games

    Joined:
    Feb 18, 2012
    Posts:
    61
    Hi, I just purchased the PUN+, it's great thank you. It's working on android devices instantly, just amazing.

    Will there be windows phone 8 support in the future?
     
  23. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    Yes, PUN+ will support Win 8 in the future. I hope in a month or so but I can't promise.
    PUN Free works with Win 8 already. I read that Unity 4.3.3. might break it (older versions definitely work) and I still have to check this out. In any case: We want to make and keep things compatible.
     
  24. games

    games

    Joined:
    Feb 18, 2012
    Posts:
    61
    Outstanding and thank you again for this quality product.
     
  25. games

    games

    Joined:
    Feb 18, 2012
    Posts:
    61
    I have a lot of PlayerPrefs saved such as character stats and would love to incorporate a database. Is photon cloud compatible with PHP / MYSQL ?

    Thanks.
     
  26. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    Photon Cloud will allow you to save some data but it's not wrapping a database.
    You can use a PHP server and MYSQL along with Photon Cloud, of course! But it's a separate connection.
     
  27. Parappa

    Parappa

    Joined:
    Jan 27, 2013
    Posts:
    77
    How can i loop through all connect players from the master client, to call an RPC. Because I want to send a different value for each client

    Something like
    for (var i = 0; i < PhotonNetwork.playerList.length; i++) {
    photonView.RPC("setPlayerNumber", PhotonNetwork.playerList.ID, i);
    }

    You cant use playerID though you have to use photonPlayer, but i dont know how to get that
     
  28. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    Just drop the ".ID" piece of your code and it should work.

    But you're not going to send them the value of 'i' like you do in your sample, are you?
    What would that be useful for?
     
  29. Parappa

    Parappa

    Joined:
    Jan 27, 2013
    Posts:
    77
    Its a 4 player battle game
    I'm just setting player numbers
    Player 1 spawns in 1 corner, player 2 spawns in another corner, etc
     
  30. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    The Player.ID already IS a player number. They might have gaps if someone leaves the room and someone else joins but those IDs could be used to identify players in a room and to sort them as well.
     
  31. zzeettoo

    zzeettoo

    Joined:
    Apr 26, 2013
    Posts:
    23
    hi there
    i am using photon cloud for a maze based multiplayer game.
    as the maze is generated randomly I have it generated only by the master client, afterwards, all others shall receive the maze data with RPC.
    The maze is a 3-dimensional int array but it seems that i cant send this with RPC?!
    is there any way to send the complete 3-dimensional array as one piece?
     
  32. Julian-S

    Julian-S

    Joined:
    May 31, 2013
    Posts:
    73
    Hello,

    I've been building up my game with Photon Cloud and it's going great, so thank you first of all. I've reached the point where I'd like to take a look at interest management. Is there a way that Photon Cloud will help me in doing this, or does anyone have an idea of where I should start?

    Thank you.
     
  33. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    This is not supported directly by Photon, so you will have to turn your maze into a byte[] or something similar. This can be sent.

    Random should generate the same sequence of values on all clients, if you use the same seed. You could probably also use this generate the maze from a single integer "seed". Make up a seed, share it in the room to initialize Random and you should be able to re-create the same maze on all clients. This would be super-lean.
     
  34. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    Cool to read you like Photon Cloud so far! Thanks :)
    Interest Management is kind of supported in Photon Cloud. I don't expect this to be what you might need.
    There are so called Interest Groups for events (the Group of a Photon View). They are limited to 255 groups and they don't adapt to actual traffic per group. If everyone is in the same place, you still get all updates and traffic might stall your game.
    Also, you might miss RPCs, which is unexpected in most cases. RPCs should always execute but if your PhotonView is in a Group you don't "listen" to, then you'll miss all data about it. This easily leads to issues.

    If you really want to get into this topic we might need to have a session about what Interest Groups do in Photon (low level) and if you need more flexibility, you might have to roll your own in Photon Server.

    What do you want to achieve?
     
  35. Julian-S

    Julian-S

    Joined:
    May 31, 2013
    Posts:
    73
    Great, thanks! Really all I'm aiming to achieve for starters is to not get updates from players a good distance away and so forth. Really just the basics of interest management for now, and then to slowly build upon that.
     
  36. AuroJj

    AuroJj

    Joined:
    Dec 13, 2013
    Posts:
    7
    Hello again.
    I attempt to return now with unity and photon cloud.
    I appreciate your help a lot.
    I'm sorry, Tobbias, in this and other occasions, I had to explain what I meant wrong. Obviously, I have to learn English :D
    I know how to place a GameObject or guitext in the avatar. What I can not understand is how to make the right call RPC, to get the message to the player.
    My intention is that the chat look like a comic.
    I was wrong about some nonsense, apparently is not complicated, but...
     
  37. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    AuroJi: I'm sorry I misunderstood you. The question how to place stuff in relation to other GOs is far more common :)

    RPCs can usually be called on any GO with PhotonView. You can call an RPC on your avatar and make it send your message. The receiving clients will call the RPC method on your avatar GO only, so you can safely place the line above that GO.

    Chat itself is shown in the PUN "Worker Demo" but that only uses one GameObject for all users, afaik.
     
  38. zzeettoo

    zzeettoo

    Joined:
    Apr 26, 2013
    Posts:
    23
    well i didnt even consider manipulating the seeds but this actually could solve a lot of my problems. I have level generation with about 20-25 random values which simply hit one after another and build up a level.
    moreover i have some game logic which starts different actions based on random numbers.
    But if i get this right, i could simply let my master client calculate a seed, share this seed with all my clients and they all use the same seed thorughout the whole game/round for all calculatiosn and decisions so they should all get the same numbers for every random.xxx call they make, right?
     
  39. AuroJj

    AuroJj

    Joined:
    Dec 13, 2013
    Posts:
    7
    GO ? :rolleyes:
     
  40. Jiro-Ng

    Jiro-Ng

    Joined:
    Jul 30, 2013
    Posts:
    5
    hi, im planing to use mysql database for my mmo... is that latest version of photon server compatible to mysql 2005? do i need to upgrade the mysql to latest version?
     
  41. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    GameObject
     
  42. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    Photon Server is compatible with any DB you want to use. It is just a normal C# runtime run by the C++ Core (which you don't have to manage).
     
  43. Jiro-Ng

    Jiro-Ng

    Joined:
    Jul 30, 2013
    Posts:
    5
    I see... thank you
     
  44. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    Greetings!

    @Tobiass - Our Dev team wants to use Photon Server Redistributable for our game but we have a couple questions and have not been able to get them answered through email so we thought we could try here. :)

    Like Minecraft or Terraria, Astral Terra is small procedural sandbox game that will allow players to host their own game and allow friends to join. Photon Server Redistributable seems perfect for this. Our problem is of course we don't understand the pricing structure and would like more details. For example, we have been Greenlit for Steam and will go on sale for Early Access in a couple months. Photon Server Redistributable biggest package is a 500 server limit. We will most likely make that many sales in the first day. We already have Photon implemented in our game for testing purposes and would love to stay with it - however this pricing structure is confusing and not really for a game that is actually selling. Can you clear this up for us? What is our options if we do even remotely well on Steam, if we want to use Photon Server Redistributable? Thanks for your time!
     
  45. bertelmonster2k

    bertelmonster2k

    Joined:
    Apr 3, 2009
    Posts:
    78
    We did not make this very clear: This means 500 concurrent servers (not copies sold): So servers online at the same time. Our experience is that this number is often overestimated.

    My guess is that

    500 Concurrent Servers (CCS)
    *20 = 10,000 Daily Active Server (DAS)
    *20 = 200,000 Monthly Active Servers (MAS)
    Assuming 50% use the server this is 400,000 downloads.

    Chris
     
  46. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    Apologies but we are still confused. So if I make 2500 sales on launch day and 502 of those players fire up their own game world/server then I am over my limit by 2? We still don't understand how this works for a game that is actually doing even remotely well in sales. It seems like we would blow right past that 500 player hosted servers in the first couple hours of being on sale.
     
  47. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    Regarding Redistributable and licensing - lets just take a hypothetical look at a Steam game and how this doesn't seem to work.

    Edited my example - see post below.

    P.S. This is a bit of exaggeration I know. In actually took 4 weeks for Rust to hit 1 million, so lets just say 1 month at a time.
     
    Last edited: Feb 18, 2014
  48. bertelmonster2k

    bertelmonster2k

    Joined:
    Apr 3, 2009
    Posts:
    78
    Sorry, I do not understand your example:

    You plan to sell 6 million copies in 3 weeks. How much do you sell a copy for?
    For 10$ your Rust game makes 60 million $ in three weeks.

    Please contact us via developer@exitgames.com and we can continue to discuss.
     
  49. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    I was using Rust on Steam as an example as a real game that this 500 server limit would never work for. Other recent multiplayer Indie or Unity games that recently released on Steam and have sold milllions of copies with the first month are 7 Days to Die and DayZ. I was just using that as an example.

    If we did 1% of the sales that Rust did on Steam, in month 1, we would sell 10,000 units. So again, in that first month, if I own the only paid for Redistributable License option which is for 500 servers running at the same time, 9,500 of my players from the 10,000 that purchased the game would not be able to play online, as that puts me 9,500 servers more than my paid for 500 servers. In games like Minecraft for Terraria (which is mentioned in Photon literature about the benefits of using Redistributable license) every player that purchases the game has the right to start up their own server. This is how that server model works.

    Exit Games pricing model, as it stands, reads as free for the first 100, than $1.25 per server beyond that up to 500 (hence the $500 price tag which assumes you are not punishing the person who pays for it by making them pay for those initial 100 servers that came free with the other package otherwise it would read as $1 per additional server). Again, great for testing purposes but we are looking for real world scenario. Again, we and anyone else who has any kind of a following will blow past that first 500 live servers in the first day of sales - we will have at least that many on launch day just in Pre-Orders alone. I don't see how as a developer we can budget with this model. It would change every week as we make more sales.

    In comparison, Ulink has a nice little system where for their Redistributable server package you pay ONCE and that license is good for 1 game/app the company is developing but unlimited server instances (and why not - the players are hosting them). Does Exit Games not offer something like this for Indies wanting to use the Redistributable License? We should be able to pay once and know we are covered - not have to worry every month about scaling up our payment to match the additional sales we made that month. Too many unanswered questions about Redistributable - it should be plain and clear on the website.

    Lastly, we already tried the email thing to you guys. Twice. And they went unanswered. We will try again though it just forces me to explain all of this over again. There is a good reason why this question keeps coming up in this thread and others on the Unity forum.
     
    Last edited: Feb 18, 2014
  50. bertelmonster2k

    bertelmonster2k

    Joined:
    Apr 3, 2009
    Posts:
    78
    We use your game as a showcase

    1) You get a free "Photon Redist" license.
    2) In return we will publish your download #s and Concurrent Online Servers in the first 2 months.

    We assume 500 concurrent servers online will be 40,000 copies sold/downloaded (per month). This way we can verify this formula and the community can benefit from the results. OK?

    We never leave mails unanswered, they go into a ticket system (supportFu which is awesome BTW) and we take care of every mail (except google decides it is spam). We love and totally support Indies: We only make money when they are making money.
     
    Last edited: Feb 18, 2014