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

UniKnowledge entry: Unity Networking the Zero to Hero guide

Discussion in 'Multiplayer' started by MikeHergaarden, Aug 23, 2009.

  1. dr-mad

    dr-mad

    Joined:
    Feb 15, 2010
    Posts:
    19
    leepo i have a question are you still gonna update the networking scripts or are you gonna let it slip

    because your project in unity 2.6 was beast and now i try to get it to work but cant get it to work i like the old idea of making a server on a pc so anyone can make a server i like to see that back in your new upgrade

    thats the reason why i love that project i have also use smartfox sever for another project but your project is nicer so every one can make a server not only the maker

    please make that back and i hope that you have the shooter function back because those 2 reasons is why i love it a online shooter

    let me know if that is comming back again

    and is there a way to make your old project work on the unity 3 let me know what i have to change to get the Network.useNat function

    or give me a hint so i can make it work again thanks for reading greets dr-mad
     
  2. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    NAT does work in U3.... master server also works..... if you know what you are doing, playing around with his tutorial even in the old 2.6.1 state in U3, a few changes should allow it to work. It is a solid base to use.
     
  3. Luken

    Luken

    Joined:
    Apr 18, 2010
    Posts:
    6
    Hello. I'm using Unity 2.6 and every tutorial so far has been working, but when I get to Tutorial 2B, when you are suppose to be able to control 2 different cubes, the client's cube won't move. I can only move the server cube.
    I built and ran the scene in the webplayer and then ran the scene in the editor and started a server there and then connected as a client in the webplayer just like in previous examples. Both the cubes are showing and both server and client show the correct position and movement of the server cube. But the client cube simply won't move in neither the client and server.
    Can anyone please help me with this problem?
     
  4. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Hi all, thanks for all Posts. The new forum wiped my notifications so i missed some Posts here.

    I'm still in Montreal ATM but I will be updating the tutorial for unity 3 asap and upload it to the unity store as well. Furthermore I recently made a networking helper class that I'll upload as well. This helper class adds some more custom made networking features.
     
  5. Luken

    Luken

    Joined:
    Apr 18, 2010
    Posts:
    6
    Great with update for Unity 3!
     
    Last edited: Nov 15, 2010
  6. Ryoni

    Ryoni

    Joined:
    Nov 16, 2010
    Posts:
    11
    Really nice tutorial Leepo. Would be nice to see all scripts in C# too.
     
  7. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    As I'm going to author it for 3.0, I will be converting it all to C#.
    Not sure if I should keep JS support too? I guess so, even though it's a pain to me :p.
     
  8. mellow991

    mellow991

    Joined:
    Nov 21, 2010
    Posts:
    11
    Hi, i am familiar with unity but am still very new to the more complex stuff (including scripting) let me first say, the tutorial is incredible and i owe you so much for making it, but none of the scenes in the project are "put together" so to speak, none of the scripts are attached, none of the materials are attached to objects etc. i'm not sure if things are supposed to be like this or not but the tutorial lead me to belieave that the examples were pre-made, please help me
     
  9. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    mellow991: Nope that's not OK. the entire project should run out of the box with everything working. You are on 3.1 I assume?
    I am going to revise the entire tutorial for a Unity store release in the next few days.
     
  10. mellow991

    mellow991

    Joined:
    Nov 21, 2010
    Posts:
    11
    Im on 3.0
     
  11. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,160
    Yes please, keep JS support.
    Thank you Leepo.
     
  12. Robotron18

    Robotron18

    Joined:
    Aug 15, 2010
    Posts:
    12
    View attachment $Example2.rar
    Example2 on C# for 2.6.1. Array like List<T>, runs significantly faster and requires no sorting, for 3.0 to modify a bit NAT. Hope this will help you. And many thanks for code.
     
    Last edited: Nov 24, 2010
  13. JeffAU

    JeffAU

    Joined:
    Mar 22, 2009
    Posts:
    387
    heya Leepo,

    Have you decided if you will keep a JS version - it would be great if you did.

    Cheers

    Jeff
     
  14. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Yeah sorry for the doubt/confusion guys, I'll keep JS as main language and offer C# conversions as well.
    So far I've added 1 extra example, new lobby code, a new main menu (host/join-direct/masterlist/quickjoin) and a reusable networking class that makes connecting masterserver stuff a lot easier (adds retry feature and custom timeouts etc.)
     
  15. dr-mad

    dr-mad

    Joined:
    Feb 15, 2010
    Posts:
    19
    wow klinkt als goed werk

    thanks for the great work

    is there gonna be a shooter element to???

    nice options you have now when are you think its gonna publish?? i use your template last time and i change alot of it to make it work but is that ok to do

    im just asking can i modify it for friends to play it

    im looking forward to it ;) ;)
     
  16. Johker

    Johker

    Joined:
    Jun 24, 2010
    Posts:
    24
    Leepo you are a Legend! Your new example is exactly what I am working on at the moment and cant wait to see how you have implemented it. I am mostly hacking your old examples to pieces with some added spice from the new U3 scripting reference.

    May I ask for a timeframe when you are looking to finish the rewrite up? Not to pressure you or anything :)
     
  17. Zu01

    Zu01

    Joined:
    Aug 17, 2010
    Posts:
    95
    looks usefull. But I couldn't use it. It is because of the older version ( probably hear that one before) But Ill keep checking. Happy scripting!
     
  18. MTracerStudios

    MTracerStudios

    Joined:
    Aug 24, 2010
    Posts:
    118
    I've tried certain unity networking games, and either noones online, or they don't work; but Red Crucible is astounding! How would one go about making something similiar to Red Crucible in every way but game play? (Instead of tanks, make it FPS, or RTS, or what have you.) What's the caliber of networking in your tutorial?
     
  19. Claws

    Claws

    Joined:
    Dec 30, 2009
    Posts:
    5
    Looking forward to the update as a c# user who wants to get into Unity networking.
     
  20. Zu01

    Zu01

    Joined:
    Aug 17, 2010
    Posts:
    95
    Yes! I got the examples to work. You just have to remove the 2nd and 3rd pragma's. After hat the tutorials are quite worth it. Just one thing, is there anywhere you know where people can get more into depth about wireless multiplayer (LAN)?
     
    Last edited: Dec 1, 2010
  21. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Wireless multiplayer (proxy)? That doesn't make much sense, please clarify yourself.

    Furthermore proxy is a wide subject as well; what do you want to know about it? You can run a proxy to proxy all unity networking traffic via your own unity-proxy server to ensure everyone is able to connect to eachother. You can not use that proxy on both the server and the client though.
     
  22. Zu01

    Zu01

    Joined:
    Aug 17, 2010
    Posts:
    95
    Sorry, I had changed proxy to LAN, I know that's anoying but in that hour I learned that proxy was much mre complicated than LAN.
     
  23. dr-mad

    dr-mad

    Joined:
    Feb 15, 2010
    Posts:
    19
    heey how is this project comming along can you say how far you are and what you have for the 3.x versions ???

    im really waiting till it comes out please reply to this

    your the greatest

    groeten dr-mad ;)
     
  24. Simba

    Simba

    Joined:
    Nov 8, 2010
    Posts:
    77
    Thanks! This is brilliant - but...
    Whenever I run any scene, I get errors: "unknown pragma: 'implicit' " and "unknown pragma: 'downcast' ".

    Any suggestions as to why this is?

    Many thanks,

    Arthur
     
  25. Simba

    Simba

    Joined:
    Nov 8, 2010
    Posts:
    77
    Oh,

    Note that I'm using the latest Unity version except 3.0 - 2.6?

    Thanks again,

    Arthur
     
  26. ProjectOne

    ProjectOne

    Joined:
    Aug 9, 2010
    Posts:
    442
    Hi, just noticed this thread as I start to look into multiplier 'how to'.
    I think your tutorial would be great for me. Will it work with the latest 3.1 version of Unity3D?

    Cheers
     
  27. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    The current online version will work (on 2.X and 3.X), but has some rough edges (#pragma implicit and downcast are added by Unity). Furthermore it doesnt cover the new NAT stuff.

    I have a greatly improved version for the unity store in the works thats aimed at Unity 3.
     
  28. Zu01

    Zu01

    Joined:
    Aug 17, 2010
    Posts:
    95
    What is a pragma anyway?
     
  29. ProjectOne

    ProjectOne

    Joined:
    Aug 9, 2010
    Posts:
    442
    cool can't wait for the Unity 3 version of your tutorial
    thanks for the info
     
  30. Simba

    Simba

    Joined:
    Nov 8, 2010
    Posts:
    77
    Thanks,

    If I built the game should it run correctly? Anyway, this is epic, and has greatly helped my game.

    Arthur
     
  31. Ortzinator

    Ortzinator

    Joined:
    Dec 1, 2010
    Posts:
    1
    Thanks for the tutorial, it's helping me a lot.

    It is in dire need of a copy editor though. For instance, what exactly does this mean?

    Code (csharp):
    1. the script is now not always only run by the objects networkview owner
    "Now not always only run"?

    I'm also having trouble understanding the code because the client and server code seems mingle and overlap in places. For instance, there's an RPC function called "SendMovementInput". Simple enough, but then you call it directly from server code which makes it betray its name (There is "send" in the name but you're not sending anything over the network). This makes it confusing.

    You also have ambiguous statements like this comment in the code:

    Code (csharp):
    1. //Call an RPC on this new networkview, set the player who controls this player
    I think you should make an effort to distinguish between a player as in NetworkPlayer and a player as in a user playing the game.

    Unless I am misunderstanding something, but even then I hope this helps you make this more clear. :)
     
  32. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    That sounds awesome. Any ETA on when it will be complete?
     
  33. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    To test the Asset Store I've uploaded a improved (and now integrated) version of my JS -> C# converter yesterday. The asset store seems to be running now so I expect to submit the whole new Unity networking project next week or the week after.
     
  34. glass22

    glass22

    Joined:
    Nov 19, 2010
    Posts:
    119
    Hey

    Couple of questions

    How can you do this conversion in C#

    var playerNumber : int = parseInt(newPlayer+"");

    Also

    Rigidbody createdCraft = Network.Instantiate(aircraft, new Vector3(-3798.679f, 131.9899f, -5415.493f), new Quaternion(0,0,0,0), pId) as Rigidbody;

    createdCraft.networkView.RPC("SetPlayer", RPCMode.AllBuffered, p);

    gives me a Null Object reference, any ideas?
     
  35. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    Awesome. You are my hero. Will it include a PDF like the original zero to hero guide?
     
  36. twoopy

    twoopy

    Joined:
    Dec 3, 2010
    Posts:
    2
    Mike, Do you have a good example on the use of 'groups'?
    I have tried various things based upon what I see in the online docs but am not able to isolate messages to groups when sending RPCs. Even when I have the server set the clients group using the incoming NetworkViewID and set it in the client.. ..the next call RPC call to that group goes to all of the clients..

    Any help would be appreciated?
     
  37. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Yes, it's an improvement to the previous tutorial.

    twoopy:
    I have no group examples as of yet, but have worked with it in the past. Hm, grouping should work and I believe you only need to assign the groups on the server. Then again to be sure you better assign them on both client servers to test.
    Note: SetScope does not work on RPCs, but groups should.
     
  38. doomprodigy

    doomprodigy

    Joined:
    Dec 12, 2010
    Posts:
    87
    This tutorial was gold, Im just having issues intergrating it into my game (I should work them out over next few days hopefully) Maybe with the next updated version include multiplayer in something other than a FPS start. And what Price range are we looking at? Im Interested :D, Going to by your converter next pay.
     
  39. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Thanks.
    I am thinking of a 50-100€ price range for the complete project, suggestions are welcome.
     
  40. doomprodigy

    doomprodigy

    Joined:
    Dec 12, 2010
    Posts:
    87
    I could probably do a 50€ - 70€ or more depending on how brilliant it is. (And if it is very drop inable sort of thing).

    Either that or you could go with something like 30€ :D :D :D

    Though it would deffinitally have to work with something other than FPSes example wise. My game is fully 2D.
     
  41. Mirek Uhlir

    Mirek Uhlir

    Joined:
    Dec 25, 2009
    Posts:
    124
    70€ is very good price
     
  42. TurtleWolf

    TurtleWolf

    Joined:
    Dec 9, 2010
    Posts:
    7
    Your tutorial has helped me understand networking more than anything so far, but I am still getting errors on my script. I am posting a beta site and the script and a jpg of the the errors at TurtleWolf.info. I am thrilled with my progress but would appreciate any help getting a second player into my reality.
     
  43. MTracerStudios

    MTracerStudios

    Joined:
    Aug 24, 2010
    Posts:
    118
    Can anyone guide me to a good SmartFoxServer/Unity3.0 guide?
     
  44. dr-mad

    dr-mad

    Joined:
    Feb 15, 2010
    Posts:
    19
    this is really hatefull

    charge money for a example first it was free now its 50-100 euro

    eerlijk vind ik dit nu een klote example ik ga hem niet kopen ;)


    sorry but i hate to hear that it now cost money im looking for another way

    then il go for the smartfoxServer its alot better then this and that is worth buying more options and more functions

    serieusly i now definitly step over to a smartfoxserver that has the new fps example with accounts and other stuff

    or i go work on my mmorpg some more with smartfoxServer
     
  45. dr-mad

    dr-mad

    Joined:
    Feb 15, 2010
    Posts:
    19
    look on the smartfox site it has a new example for 3.x and there you must ask the questions here almost nobody know how the scripts work and try using the documentation on smartfoxserver site

    that is better to try i use the fps example from smartfoxserver 2.x that is for unity 3.x and before i use the 1.6.9 version with unity 2.x but there i make a new mmo ;) now im converting it ;) till it works on 3.x unity

    just look for the extensions to make it better
     
  46. the_gnoblin

    the_gnoblin

    Joined:
    Jan 10, 2009
    Posts:
    722
    Leepo, thanks! :)
     
  47. Zu01

    Zu01

    Joined:
    Aug 17, 2010
    Posts:
    95
    Your tutorials where a good start, I finally got what I needed. Anyone reading this might also want to look into the unity multiplayer tutorial and the post called from lan...to wan (or man) the last couple posts should help you figure it out.
     
  48. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    Leepooooo..... When's the premium version coming to the asset store?!
     
  49. SrBilyon

    SrBilyon

    Joined:
    Jul 13, 2010
    Posts:
    291
    Can't wait for the new 3.0 tutorial. I just recently got into networking for Unity and started using your first tutorial project after discovering that Unity's Networking Example wasn't working right for Unity 3.0.

    Anyway, great job with the current tutorial and I can't wait for it to appear in the Asset Store (hoping that it is leaning towards the $50 end (or maybe even $30, lol)) I'll still buy it regardless.
     
  50. TheLorax

    TheLorax

    Joined:
    Mar 25, 2007
    Posts:
    86
    Any news on this???