1. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  2. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  3. We’re giving 2017.1 beta testers a chance to win t-shirts and a Nintendo Switch. Read more on the blog.
    Dismiss Notice
  4. We want to know how you learned Unity! Help us by taking this quick survey and have a chance at a $25 gift card
    Dismiss Notice
  5. Unity 5.6 is now released.
    Dismiss Notice
  6. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice

Unity Multiplayer Collection of Multiplayer samples

Discussion in 'Multiplayer Networking' started by seanr, Sep 17, 2015.

  1. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
  2. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
  3. GenaSG

    GenaSG

    Joined:
    Apr 19, 2014
    Posts:
    88
  4. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    865
    I would like to contribute to this list but I can't seem to upload the project zip file here. Where else can I do so?
     
  5. GenaSG

    GenaSG

    Joined:
    Apr 19, 2014
    Posts:
    88
    You can upload your code to github.
    And share a link to the repository here.
     
  6. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    865
    Here's the project link. This project shows how to make a non-player object as a player-controllable unit in a typical RTS application. (It's not a game, just an boring RTS sample of clicking here and there.)

    To test the project out, you need to first CTRL+B (Build) the project into a runnable executable, and then use the editor to connect to the runnable.

    Hopefully, it can help others out.
     
    Last edited: Sep 26, 2015
    Nikolasio and pKallv like this.
  7. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    865
  8. rikey

    rikey

    Joined:
    Mar 3, 2015
    Posts:
    147
    Last edited: Sep 29, 2015
  9. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    865
    New RTS sample project. This shows how to spawn non-player game objects from other non-player game objects. It may seem trivial to do, but just to get UNET working takes a lot of effort.
     
    Braza likes this.
  10. sfoust

    sfoust

    Joined:
    May 18, 2011
    Posts:
    18
    Update: A much cleaner version of a simple turn-based multiplayer Rock Paper Scissors game is now available below (my apologies to anyone who download the pile of garbage I posted earlier).

    Here is a simple turn-based example game of Rock Paper Scissors in two C# files (RPS_Player and RPS_Server) which are both components of a player prefab. (See attach RPS_10112015.unitypackage file below).

    This solution for a RPS game seems to work pretty well. But, I'm new to UNet (and networking in general) so I'm sure this is not the MOST elegant solution that could be created (feel free to post improve examples).

    This approach uses [ClientRpc] to sync data between player and player instance.

    Please have a look and please post better solutions.
    Critiques are much appreciated. :)

    Data Flow Diagram for RPS.png
    [​IMG]
     

    Attached Files:

    Last edited: Oct 13, 2015
    Braza likes this.
  11. rikey

    rikey

    Joined:
    Mar 3, 2015
    Posts:
    147
    3 part series on UNET client-server communication, client-side prediction and server reconciliation, and quality of service channels. All parts contain a link to get a sample project that uses everything taught in the series.

    Part 1: http://www.gamasutra.com/blogs/Chri...torial_Part_1_of_3__Introducing_the_HLAPI.php
    Part 2: http://www.gamasutra.com/blogs/Chri...Side_Prediction_and_Server_Reconciliation.php
    Part 3 is in 6 parts:
    http://www.gamasutra.com/blogs/Chri...lation_Part_1_of_6__Break_Into_Components.php
     
    Last edited: Apr 2, 2016
    seorge_ru and Dmitriy-Yukhanov like this.
  12. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
  13. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
  14. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
  15. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
  16. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    113
    This is really a wonderful thread, thank you for keeping it updated. Lots of useful information.
     
  17. Kombiice

    Kombiice

    Joined:
    Jan 20, 2015
    Posts:
    28
    Yeah thats helpful
     
  18. Justice0Juic3

    Justice0Juic3

    Joined:
    Apr 29, 2013
    Posts:
    123
    Hi there.
    I'm kinda stucked right now. Regarding the Lobby-sample project, I can't seem to find the logic behind a team-selection. Can anybody please do some explaining?

    Or could you guys (the official UNet developers) come up with a sample project for this? :(
     
  19. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    865
    The lobby example is the official sample.
     
  20. buzheteng

    buzheteng

    Joined:
    Feb 29, 2016
    Posts:
    4
    thanks for sharing~:p:p
     
  21. jamiejammas

    jamiejammas

    Joined:
    Aug 1, 2015
    Posts:
    1
    Are there any projects on here where an external computer can connect to a game someone is hosting without using unity's master server?
     
  22. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    865
    Just connect via external IP address. No need for master server.
     
  23. Olipool

    Olipool

    Joined:
    Feb 8, 2015
    Posts:
    54
    http://bitbeast-games.com/wp-content/uploads/2016/06/SuperCars-Networking.zip

    Just wanted to add my sample project here. It evolved after following the networking tutorial in the manual. I adapted it to a 2D context and added more and more functionaliy I wanted to test out.
    It is a small car racer with a complete gameloop (getting ready, driving, show final standings), you can race against bots and other clients can connect anytime, replacing bots and if a player drops out a bot will take over his car. You can chat ingame and you can select a bot's car of your color and use it to block enemies or help them to the finish line :)
    It has some other not networking solutions as well, because I stumbled over them unexpectedly (driving a car above and below a bridge in a 2D context or programming a custom shader to colorize the cars for example). The graphics are taken from the old Amiga game Supercars and I hope in this context this will not cause any copyright issues.

    This is not the best code, it should be considered as a playground where you can test things out. It has evolved in that way so the class structure is a bit wild :) Also the networking code may not be what is considered as best practice, maybe there are even some faults, but I thought it could serve as a good starting point to see how certain things work together and as a playground to experiment in. It doesn't use any advanced features yet like client prediction, lag compensation etc. (at the moment the network transform just fires as often as possible).
    I added comments as well but if you have any questions feel free to ask. Also if you think the project has severe issues and is awefully implemented: please shoot as well. I'm eager to learn how to use UNet in the best way possible, especially handling collisions... :)
    [​IMG]
     
    Last edited: Jun 11, 2016
    errandfox, bingolino and notseanr like this.
  24. Nikolasio

    Nikolasio

    Joined:
    Dec 6, 2014
    Posts:
    24
    @asperatology Thank you very much!! Based on your sample projects I made a non player object with client authority draggable over the network.

    /*Still don't grasp it fully as I'm failing to identify the local player's non player object with a different sprite. I'm trying to swop the sprite in the OnStartLocalPlayer()...
    Any thoughts would be helpful.*/

    EDIT: I changed the color to differentiate between the players (sprite swop is also possible)

    Cheers,
    Nikola
     

    Attached Files:

    Last edited: Feb 28, 2017
  25. richard-lee

    richard-lee

    Unity Technologies

    Joined:
    Jul 14, 2015
    Posts:
    39
    Cross posting from Learn.

    https://forum.unity3d.com/threads/tanks-reference-project-for-unity-multiplayer-q-a.456783/

    Built on Unity's tutorials, Tanks!!! goes further, turning them into a live, fully featured, Multiplayer game. Get the game now, on iOS, Android, MacOS, or Windows. Then, get the source, available from the Asset Store!

    [​IMG]

    [​IMG][​IMG][​IMG][​IMG]

    Tanks!!! Reference Project is a Unity Multiplayer project that is available for free on the Asset Store. If you’ve gone through the Multiplayer tutorials on our site, it should look familiar. It’s based on the existing Tanks! tutorials, but amped up into a fully featured game. This project includes code, assets, reference material… everything you need to build a the full game.

    We made this project because we’ve seen and gotten a lot of direct feedback regarding how one implements Multiplayer in a production environment. So, it demonstrates how to solve some common Multiplayer challenges like compensating for latency and cheating.

    Because this is architected as a production-ready game, it may be harder to digest than the existing Tanks! tutorials. So to ease people in, this project comes with a complete reference guide. You can also watch 3 part video walkthrough on Youtube right now.
    So, try out the game and then download it from the Asset Store. Then, let us know what you think on the Learn thread. I’m especially curious if this game really does help people understand Unity Multiplayer better and if we at Unity should create more “reference projects” like this one. PM me if you have detailed feedback.
     
    Olipool, danreid70 and Luke-Lamothe like this.
  26. danreid70

    danreid70

    Joined:
    Aug 28, 2010
    Posts:
    193
    Definitely would love more example projects like this!!!