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 New Photon Unity Networking Tutorial Series

Discussion in 'Multiplayer' started by Oliver-Eberlei, Apr 17, 2014.

  1. Oliver-Eberlei

    Oliver-Eberlei

    Joined:
    Jun 12, 2011
    Posts:
    110
    Hello everyone,

    I am very proud to announce a project I’ve been working on over the last month: A tutorial series on how to create a high speed multiplayer game with the Photon Networking engine. The project consists of online tutorial videos, text documentation, the complete source code and a working multiplayer game for you to check out. Hopefully this project will help you start your own online multiplayer game.
    I have been using Photon and Unity together for several years now and for me it is one of the easiest networking engines to get setup and running. Through a couple of my projects, the guys at exitgames (the creators of Photon) approached me about this Tutorial series and they supported me all the way throughout the project.

    This is also the reason why we can give most of the project away for free. There are free video tutorials, a free project overview and the demo itself, which you can play for free. However, if you like this series and would like to support us so that we can create more

    please consider purchasing the source code for this project in the Unity Asset Store.

    Warning: You'll need to setup the proper project settings before being able to play the game in your editor. The correct project settings folder is zipped and included in the project. See the documentation for more info

    The source code is very well documented and it will give you a detailed glimpse into a multiplayer project. We are already planning new content and the same asset store package will be updated with all the new content, once it arrives. Eventually, we want this project to evolve into a fully functioning multiplayer game with all the bells and whistles you know from commercial multiplayer games.
    For example, here are some of the topics we want to cover in future episodes:
    • Chat
    • Serverbrowser
    • Multiple Maps
    • Multiple Game Modes
    • Lag Compensation
    • Cheat Protection
    • User Authentication
    If you want to learn more about a specific topic that isn’t listed here, please let us know and we will adjust our plans accordingly.
    We are planning for this project to evolve into an ultimate resource on how to create online multiplayer games with Unity and Photon and we are looking forward to your questions and feedback. This project was created for you and with your input we want to steer it so that every question you have about online multiplayer will be answered.
     
    Last edited: May 5, 2014
  2. roka

    roka

    Joined:
    Sep 12, 2010
    Posts:
    589
    Really love the video, i'm sure that this will help a lot of user

    Thank
     
  3. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    Hi,
    Looks great, bought it but...

    The documentation linked above is not in the download
    There is no documentation on setting up the inputs, and it does not work properly without them being set up
     
    chulini likes this.
  4. Glader

    Glader

    Joined:
    Aug 19, 2013
    Posts:
    456
    While I use Photon Server SDK and not Cloud or PUN the quality of your videos seems amazing. It seems like a lot of planning and editing went into these, great job!
     
  5. Oliver-Eberlei

    Oliver-Eberlei

    Joined:
    Jun 12, 2011
    Posts:
    110
    Thank you for commenting on the videos. I'm glad you like them :)

    @sonicviz: Wow. That is indeed a massive oversight on my part. I've uploaded the ProjectSettings here
    www.hammer-labs.com/skyarenatutorial/ProjectSettings.zip

    Just unzip it into your ProjectSettings folder and overwrite the old files (close Unity before you do that). This should setup the proper input variables and tags used in the project.
    I will upload a fixed project immediately. Thank you for bringing that to my attention.
     
    Last edited: Apr 22, 2014
  6. Smartline-Games

    Smartline-Games

    Joined:
    Aug 15, 2013
    Posts:
    67
    "This is also the reason why we can give most of the project away for free."


    Wasn't it meant to release this for free?
    +The link for the ProjectSettings don't even work.
     
  7. Oliver-Eberlei

    Oliver-Eberlei

    Joined:
    Jun 12, 2011
    Posts:
    110
    Hmm, the server is acting up today. I am currently investigating what's going on. I've uploaded the files into my dropbox and updated the links in the meantime.

    I meant the videos, pdf documentation and the game are viewable/playable for free and, if you like them, you can help out by purchasing the source code. Sorry if that wasn't clear.
     
    Last edited: Apr 22, 2014
  8. Smartline-Games

    Smartline-Games

    Joined:
    Aug 15, 2013
    Posts:
    67
    @Oliver Eberlei

    Thanks for responding ;) and good luck on your further gamedevelopment!
     
  9. Smartline-Games

    Smartline-Games

    Joined:
    Aug 15, 2013
    Posts:
    67
    Hey, also thanks for updating the links. Now I can actually experience what the package looks like in realtime. I'd like to see an update with a server list or something like that: I'm pretty interesed in it ;)
     
  10. Oliver-Eberlei

    Oliver-Eberlei

    Joined:
    Jun 12, 2011
    Posts:
    110
    This is planned for the next round of videos :) But it'll take a while to produce them. We are currently targeting June for the second part
     
  11. eastes

    eastes

    Joined:
    Sep 1, 2012
    Posts:
    59
    Thank you. Best money I've spent in the asset store, to date.
     
  12. eastes

    eastes

    Joined:
    Sep 1, 2012
    Posts:
    59
    I've been playing with this all day. Unfortunately, even running locally, there's a sudden jolt every second. Is this normal? Have I done something wrong?

    Please see here https://www.youtube.com/watch?v=J4X3KF8ZSY0

    EDIT: this video is now watchable
     
    Last edited: May 10, 2014
  13. Oliver-Eberlei

    Oliver-Eberlei

    Joined:
    Jun 12, 2011
    Posts:
    110
    Hi eastes, the jolt is certainly not intended.
    Can you set the video access to public or unlisted? Otherwise I can't see it
     
  14. konsnos

    konsnos

    Joined:
    Feb 13, 2012
    Posts:
    121
    Thanks for the tutorial series Oliver :)

    Is the project still unpatched?
     
  15. Oliver-Eberlei

    Oliver-Eberlei

    Joined:
    Jun 12, 2011
    Posts:
    110
    Hi konsnos,

    I'm glad you like it. The project is already patched, however you still need to apply the project settings manually. They're now included in the projects /downloads/ folder. I'll create a script for the next version that does this automatically. It's weird to jump through hoops like that, but I guess the reason is that people don't destroy their project settings when importing assets from the asset store.

    I changed to warning text in the first post accordingly.
     
  16. konsnos

    konsnos

    Joined:
    Feb 13, 2012
    Posts:
    121
    Gotcha ;) Thank you.

    And by the way, the game kicks ass :D I wish it had more players to play against, but even alone I love the movement of the ship. Really nice job.
     
  17. spectra

    spectra

    Joined:
    May 6, 2014
    Posts:
    11
    Nice one, Oliver... Any plan to optimize the game on mobile devices?

    I'd purchased this baby +/- 4 hours ago.

    Can't wait for nice update. Why? Because I always love updating software/asset that I've purchased. :)
     
  18. Oliver-Eberlei

    Oliver-Eberlei

    Joined:
    Jun 12, 2011
    Posts:
    110
    Hey spectra, I'm glad you like it :)
    We currently don't have plans for a mobile version since this tutorial is focused on the real-time multiplayer part.
    Photon also works on mobile so the process should be the same described here.

    If you like updates, you'll be getting a present in June :)
     
  19. spectra

    spectra

    Joined:
    May 6, 2014
    Posts:
    11
    OK, Great.

    Yeah, I will wait for June. It's my month of birth. :)

    Uhmm.. I think the price should be normalized very soon. $25 is still a funny price.

    Have a nice day, Oliver and Exit Games team.. Success for this project.
     
  20. Brendonm17

    Brendonm17

    Joined:
    Dec 9, 2013
    Posts:
    43
    So oliver.... Ive never purchased anything off of the asset store before, and was wondering what i get in this package? like what do i get right of the box? I know i have to set up a few settings, but is it multiplayer right out of the box? Or is it a single player fly around kind of deal? And how hard would it be to set up joystick control (like on your ouya version?), because if i purchase this, i would like to replace pretty much all your models... but keep the code kinda deal, and publish this to the gamestick store. if possible, please email me at Steampunkstudent@gmail.com

    Thank you,
    Brendon
     
  21. eastes

    eastes

    Joined:
    Sep 1, 2012
    Posts:
    59
    I've been playing with this all day. Unfortunately, even running locally, there's a sudden jolt every second. Is this normal? Have I done something wrong?

    Please see here https://www.youtube.com/watch?v=J4X3KF8ZSY0
     
  22. Brendonm17

    Brendonm17

    Joined:
    Dec 9, 2013
    Posts:
    43
    I didn't get a reply.. So I decided to purchase the asset anyways! :D
     
  23. Brendonm17

    Brendonm17

    Joined:
    Dec 9, 2013
    Posts:
    43
    As of now, when do you think part 2 will be released? I see it says june, but i wondering if it is late or early june.. I would love to see your method of lag control. Thankyou
     
  24. Oliver-Eberlei

    Oliver-Eberlei

    Joined:
    Jun 12, 2011
    Posts:
    110
    Hey guys, sorry for the late reply. I forgot to subscribe to this thread and didn't get the email pings that there are new posts :)

    @Bendonm17: Thanks for purchasing :) The package already has gamepad controls which can be switched on the fly between gamepad and keyboard/mouse. Season 2 is in production now but I still rather just say "june", because life happens all the time :) I can commit to a date when it's done. Sorry if its too unspecific for now, I hope to get it out in june as early as possible, but I don't want to make any promises.

    @eastes: Ah, it would be interesting to know how high your ping is. You can output your ping to the console with this line
    Code (csharp):
    1. Debug.Log( PhotonNetwork.GetPing() );
    Even if you run two instances of the game locally, they're still connecting to the Photon server so you'll get a certain amount of lag/delay from the communication between your computer and the server.

    The jolt is caused in ShipMovement.cs in line 270:
    Code (csharp):
    1.         if( Vector3.Distance( transform.position, exterpolatedTargetPosition ) > 2f )
    2.         {
    3.             newPosition = exterpolatedTargetPosition;
    4.         }
    Basically it is a result of the networked simulation and the prediction model running out of sync. It can probably be handled more gracefully by rubber banding the ship to the correct position instead of teleporting it. I will make it smoother for part 2 of the tutorial. Thanks for reporting it.
     
    Last edited: May 19, 2014
  25. eastes

    eastes

    Joined:
    Sep 1, 2012
    Posts:
    59
    Thanks for the heads up! It makes sense about my ping still applying when local and the rubberbanding technique makes sense too.
     
  26. Mike-Pellecchia

    Mike-Pellecchia

    Joined:
    May 23, 2014
    Posts:
    6
    Thank you for the tutorial. I am just starting to dive into Unity Networking and i plan on using photon. These gave me a great head start. The thing I am most concerned about is cheating so I would love to see those videos!
     
  27. Brendonm17

    Brendonm17

    Joined:
    Dec 9, 2013
    Posts:
    43
    Hey Oliver, I was wondering why (when on slow connections) the bullet shoots WAY in front of the ship? does this also have to do with the pings? Would it be hard to spawn the bullet right in front of the ship? Thanks Oliver, all help is appreciated!
     
  28. Oliver-Eberlei

    Oliver-Eberlei

    Joined:
    Jun 12, 2011
    Posts:
    110
    @Brendonm17: Yea this has to do with pings. I talked about this issue a little bit at the end of video 3: http://youtu.be/ozBmZ9FoN_o?t=8m6s (starts at 8:06)
    It's not ideal, especially since it looks weird when the laser is created so far in front of the ship. This is one of these situations where smoke and mirrors have to be used to cover up network latency. A good solution might be to make some kind of visual hack. Maybe spawn the laser directly in front of the ship and make it fly faster in the beginning until it catches up with it's real position.
    Basically make the lasers collision object and visual object two seperate objects and move them independently. The collision object will be moved how the laser should really fly and the visual object makes some kind of interpolations to make it look better.

    Since the laser is quite fast, it might be possible to get away with something like this. It's hard to say without testing it.
     
  29. rubble1

    rubble1

    Joined:
    Apr 25, 2010
    Posts:
    84
    Hi Oliver,

    Great kit you have here.

    I was just wondering how ground collisions work in here. How do I adjust the ground position?
    Is it possible to increase or decrease the "height" of the level? How does that work?
     
    Brendonm17 likes this.
  30. Brendonm17

    Brendonm17

    Joined:
    Dec 9, 2013
    Posts:
    43
    Thanks Oliver, I think I understand now! Also, I agree with @daniel_coes, is there any way to adjust the level height? i didn't see any hidden colliders or anything... Are you just testing the height of the players ship (In code) and setting its current height to whatever you want? Thanks.
     
  31. Oliver-Eberlei

    Oliver-Eberlei

    Joined:
    Jun 12, 2011
    Posts:
    110
    You can find that piece of code in ShipMovement.cs on line 465

    Code (csharp):
    1. //We don't want the player to fly too close to the sun or the ground. It's hurtful
    2. newPosition.y = Mathf.Clamp( newPosition.y, 0.5f, 50f );
    I chose this simple solution since the tutorial is focused on networking and I didn't want to bloat up the code with unneccessary collision stuff.
     
  32. Aleksr9

    Aleksr9

    Joined:
    Jun 19, 2014
    Posts:
    1
    Loved the tutorial!
    Any updates on when the 2nd part is being released?
     
    Brendonm17 likes this.
  33. BurningthumbStudios

    BurningthumbStudios

    Joined:
    Apr 28, 2008
    Posts:
    95
    Looking forward to the update (June is here). I did notice an issue with the blob shadow still being projected when the ship is destroyed because a blob projector does not have a renderer. So in the file Ship.cs I modified the method SetVisibility to also toggle Projectors - I know there is only one projector but I figured I may as well handle the possible case of more. Here is the updated code for the method:

    Code (CSharp):
    1. voidSetVisibility( boolvisible )
    2. {
    3. m_IsVisible = visible;
    4.  
    5. Renderer[] renderers = GetComponentsInChildren<Renderer>();
    6. Projector[] projectors = GetComponentsInChildren<Projector>();
    7.  
    8. for( inti = 0; i < renderers.Length; ++i )
    9. {
    10. renderers[ i ].enabled = visible;
    11. }
    12.  
    13. for( inti = 0; i < projectors.Length; ++i )
    14. {
    15. projectors[ i ].enabled = visible;
    16. }
    17. }
     
  34. Bonbono

    Bonbono

    Joined:
    Dec 17, 2012
    Posts:
    4
    Hi I wonder where in the code does it change the ships color team! don't find it! Would it be possible in the planed tutorials to implement a menu where I can choose different ships and different map!

    I like this, but need this to choose different ships that I have made!
    Thanks in Advance!
    It´s soon July hope part 2 it will come out soon!
    Keep the good job!
     
  35. BurningthumbStudios

    BurningthumbStudios

    Joined:
    Apr 28, 2008
    Posts:
    95
    I'm working through the project and I found the main menu did not scale too well for different screen sizes. So I changed the BackgroundImage in the MainMenu scene by setting its Transform Scale X=1, Y=1 and the GUITexture Pixel Inset to all zeros. The aspect ratio is a bit off on some display sizes so I may do something else. I also found the text rendered by the MainMenu.cs GUI to do odd things on different screen resolutions so I change the LoadStyles() and OnGUI() methods as follows:

    Code (CSharp):
    1.     void LoadStyles()
    2.     {
    3.         if( TextStyle == null )
    4.         {
    5.             TextStyle = new GUIStyle( "Label" );
    6.             TextStyle.font = TextFont;
    7.             TextStyle.fontSize = Screen.width / 25;
    8.             TextStyle.alignment = TextAnchor.MiddleCenter;
    9.         }
    10.     }
    11.  
    12.     void OnGUI()
    13.     {
    14.         LoadStyles();
    15.  
    16.         GUI.color = new Color( 1f, 1f, 1f, Mathf.Sin( Time.realtimeSinceStartup * 4f ) * 0.4f + 0.6f );
    17.  
    18.         float labelWidth = Screen.width * 0.75f;
    19.         float labelHeight = Screen.height * 0.15f;
    20.  
    21.         string label = "";
    22.  
    23.         switch( PhotonNetwork.connectionState )
    24.         {
    25.         case ConnectionState.Disconnected:
    26.             label = "Press any key to connect";
    27.             break;
    28.         default:
    29.             label = "Connecting...\n" + PhotonNetwork.connectionStateDetailed;
    30.             break;
    31.         }
    32.  
    33.         GUI.Label( new Rect( ( Screen.width - labelWidth ) * 0.5f, ( Screen.height - labelHeight ) * 0.85f, labelWidth, labelHeight ), label, TextStyle );
    34.     }
     
  36. Oliver-Eberlei

    Oliver-Eberlei

    Joined:
    Jun 12, 2011
    Posts:
    110
    Hi guys. I wanted to post a quick update. I am currently filming the next batch of videos. The code is already completed. However there were some delays (I released my first game on Steam :) ) which is why the videos take a little bit longer.

    Sorry to keep you waiting.

    @BurningThumb: Thank your for your fixes. I'll implemeted in the next update. The GUI stuff will be updated anyway since new GUI elements will be added. But I will try to fix the code that remains similar.

    @Bonbono: Take a look at the function SetTeamColors in ShipVisuals.cs
     
    Brendonm17 likes this.
  37. Brendonm17

    Brendonm17

    Joined:
    Dec 9, 2013
    Posts:
    43
    @Oliver Eberlei, you released a game on steam! whats it called i would love to take a look at it! :)
     
  38. Cjreek

    Cjreek

    Joined:
    Apr 23, 2013
    Posts:
    33
    @Brendonm17 It's probably "Farm for your life". (there are videos of it on his youtube channel)
     
    Brendonm17 likes this.
  39. Oliver-Eberlei

    Oliver-Eberlei

    Joined:
    Jun 12, 2011
    Posts:
    110
    It is, I just didn't want to do a selfish plug ;-)
     
    Brendonm17 likes this.
  40. BananaClipStudio

    BananaClipStudio

    Joined:
    Jul 23, 2012
    Posts:
    13
    is there an ETA? I just bought the tutorial just for the part 2. Good luck with your game
     
  41. Brendonm17

    Brendonm17

    Joined:
    Dec 9, 2013
    Posts:
    43
    If your American, happy july 4th! :)
     
  42. MetalSoul666

    MetalSoul666

    Joined:
    Sep 16, 2013
    Posts:
    19
    Its july 8

    I just can't wait for part 2

    Really want figure out the custom properties how they works
     
    Brendonm17 likes this.
  43. Brendonm17

    Brendonm17

    Joined:
    Dec 9, 2013
    Posts:
    43
    @Oliver Eberlei is this a good way to set game modes using custom properties? I have been messing around with photon and have been trying this:

    Code (JavaScript):
    1. var gameSettings : ExitGames.Client.Photon.Hashtable = new ExitGames.Client.Photon.Hashtable();
    2. gameSettings["GameMode"] = GameMode[num].ToString();
    It seems to be working VERY well, but is there a better method? This is all in Javascript but it seems to be the same ways as c#. oh, and would this be the correct way to call the new variable:

    Code (JavaScript):
    1. GameMode = PhotonNetwork.room.customProperties["GameMode"];
    This is what I tried in my FPS, and it seems to work. If there is any better way, I'm all ears! :) Thanks!
     
  44. Brendonm17

    Brendonm17

    Joined:
    Dec 9, 2013
    Posts:
    43
    Hopefully part 2 comes out soon.. I hate to sound needy and all but a lot of us have been waiting for part two. I need to figure out how to change maps for my FPS, and plus June was about a month ago... I know you are busy and all but you could tell us if it is going to be postponed. Sorry and stuff, but you guys have made the best tutorial on photon around, and we are all kind of jumpy and excited for part 2 to come out. Please update us on how far you are.. Thanks.
     
  45. Oliver-Eberlei

    Oliver-Eberlei

    Joined:
    Jun 12, 2011
    Posts:
    110
    :) Thanks Brendonm17, that means a lot.

    In fact, the videos for part 2 are done! I've made them public already so you can at least get a preview of what's to come. We are putting the finishing touches on the code, commenting everything, creating new screenshots for the new features etc.

    The new package will be ready and online next week and that will also be the time where we raise the price to its regular value of 25$. So this weekend is the last chance for your to get the whole series for just 10$. Grab it while you can :)

    Oh, and here are the links to the new videos, I hope you enjoy them :)

    Custom Properties and Room Browser - Part 2 Lesson 1


    Custom Player Properties and Gamemodes - Part 2 Lesson 2


    Matchmaking - Part 2 Lesson 3


    Chat - Part 2 Lesson 4


    You'll see that lesson 1 still has some helper lines visible in the beginning. I am uploading the fixed version now but they disappear quite quickly so it's still possible to enjoy the video. Just some of the stuff that will get fixed until the launch next week :)
     
    Pulov and Brendonm17 like this.
  46. Oliver-Eberlei

    Oliver-Eberlei

    Joined:
    Jun 12, 2011
    Posts:
    110
    Oh and Brendomn17: That's exactly how I would do it. If it works, don't fix it :)
     
  47. Brendonm17

    Brendonm17

    Joined:
    Dec 9, 2013
    Posts:
    43
    @Oliver Eberlei thanks! And sorry for being so straight forward... I'm just the kinda person that likes set dates.
     
  48. stvster

    stvster

    Joined:
    Mar 4, 2013
    Posts:
    70
    WOW!,Thanx Oliver for the updated videos.Seeing the menu screens and game options was a THRILL!
    I'm so glad I purchased this Amazing package.
    Thanx again.
    also Thanx to Unity and Exitgames.
     
    Brendonm17 likes this.
  49. stvster

    stvster

    Joined:
    Mar 4, 2013
    Posts:
    70
    THANX! Oliver for the Update(V2).I'd write more but I HAVE to go play with Sky Arena.:D
    EDIT:
    What can i say,This package is all and more than I anticipated it to be.
    I think the union of Hammer Labs and Exitgames was forecast by Nostradamus.If not he should have!
    Well Done to all involved and Thanx again.:)
     
    Last edited: Jul 17, 2014
  50. Gunhi

    Gunhi

    Joined:
    Apr 18, 2012
    Posts:
    300
    I got this error

    ====
    Connect() failed, because SocketImplementation or socket was null. Set PhotonPeer.SocketImplementation before Connect().
    ====
     
    Last edited: Jul 16, 2014