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. Unity 2017.1 beta is now available for download.
    Dismiss Notice
  5. Unity 5.6 is now released.
    Dismiss Notice
  6. Get further faster with the Unity Plus Accelerator Pack, free for new Unity Plus subscribers for a limited time. Click here for more details.
    Dismiss Notice
  7. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  8. Learn how you'll soon be able to publish your games to China in four simple steps with Xiaomi. Sign up now for early access.
    Dismiss Notice

Tanks!!! Reference Project, for Unity Multiplayer Q&A

Discussion in 'Community Learning & Teaching' started by richard-lee, Feb 17, 2017.

  1. richard-lee

    richard-lee

    Unity Technologies

    Joined:
    Jul 14, 2015
    Posts:
    37
    [​IMG]

    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 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 this 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.

    If you run into any technical issues or questions, reply to this thread. Alec (AlecLarsen1989) was lead getting this project shipped and will also answer questions directly.
     
    Troast, eses, MD_Reptile and 4 others like this.
  2. DungDajHjep

    DungDajHjep

    Joined:
    Mar 25, 2015
    Posts:
    24
    stuck here when use android phone to join my unity editor host
     

    Attached Files:

  3. AlecLarsen1989

    AlecLarsen1989

    Joined:
    Feb 7, 2017
    Posts:
    11
    Can you send through more details? For example, did you deploy your own instance of the game to your Android device? The Live versions (on Google Play/App Store) are not compatible with the version from the asset store.

    If you did deploy your own version to your Android device then are you using Unity 5.5.1? If you are, could you possibly send through the adb logcat dump from your Android device, as this would allow us to pinpoint the problem. If you need any further assistance, feel free to reach out :)
     
    Last edited: Feb 28, 2017
  4. Gymhgy123

    Gymhgy123

    Joined:
    Jan 15, 2017
    Posts:
    4
    Where's the difference between the Tanks! multiplayer project? Don't they both allow multiplayer, except this one is more cartoony?
     
  5. richard-lee

    richard-lee

    Unity Technologies

    Joined:
    Jul 14, 2015
    Posts:
    37
    This one uses the Multiplayer services (Relay, Matchmaker). It's also architected as a production game, which is important for multiplayer where you have network-specific considerations to workaround e.g. cheating, compensating for latency.
     
  6. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    190
    Thanks for bringing us this nice demo project! :)

    I've noticed, that all models have two versions of the same mesh, one is used as the default visible mesh, and the other has smoothed normals and is used to draw the outline and cast shadows. Is there any specific reason for this setup? I thought about writing custom smooth normal data into a separate uv channel on model import and then let my shader use that channel to get custom normals only for the outline part, so I wouldn't have to import double the amount of meshes. Does this lead to multiple shader passes or somehow break batching or why would I want to manually import separate models?
     
  7. IronmanXXX

    IronmanXXX

    Joined:
    Aug 7, 2013
    Posts:
    8
    Just started playing around with Tanks!!!

    I'm getting 126 errors.

    for example:
    'TankHealth' does not contain a definition for ''TANK_SUICIDE_INDEX"

    I went poking around TankHealth.ca

    I am seeing a bunch of place holder functions.
    For example:
    public void TakeDamage(float amount)
    {
    // Adjust the tank's current health, update the UI based on the new health and check whether or not the tank is dead.
    }


    Is this expected?
    I did a reimport and got the same results.
    I have watched the 3 videos and read the TanksReference.pdf

    Is there somewhere that goes into what should be coded for these functions?
     
  8. IronmanXXX

    IronmanXXX

    Joined:
    Aug 7, 2013
    Posts:
    8
    I believe my issue was I imported over the old Tanks tutorial files and some old files got left behind.
    I do not see _Complete-Game.unity, _Complete-Game.meta, _Completed-Assets.meta like the original Tanks did.

    Building and running works.
     
  9. AlecLarsen1989

    AlecLarsen1989

    Joined:
    Feb 7, 2017
    Posts:
    11
    Glad you managed to get it sorted. If you have any more questions, feel free to ask :)
     
  10. AlecLarsen1989

    AlecLarsen1989

    Joined:
    Feb 7, 2017
    Posts:
    11
    That's a great question!

    The reason it's a different mesh is a fairly simple optimisation. While I don't anticipate any hiccups with your proposed approach, it would defeat the true main purposes of smoothing out the normals in the first place:

    The mesh with smooth normals and no UVs means that Unity can represent that mesh without needing to split verts at UV islands or hard normal edges, so the same geometry ends up with fewer verts sent to the GPU. This means we could render the shadows and outlines with fewer overall verts, though with a slight extra memory cost.

    It also opened up the possibility to literally eliminate verts that would not contribute to the shape of the shadow or outline (although in practice we found we didn't really need to do this all that much, if it all). You can generally get away with using a significantly lower-resolution mesh for a shadow without any visible artifacts. It's also useful to do this so that you can make thin things that cause shimmery shadows thicker in the shadow mesh, to help eliminate those graphical artifacts.

    The other, more pragmatic reason for smoothing the normals is for the outline portion of the effect (although there is no reason the outline mesh and shadow meshes need to be the same, it just made sense to do it in this case). It's a fairly naive outline approach that simply pushes verts outwards along their normals, and if there's a vert cut for hard shading, the faces will split apart and there will be gaps in the outline. While your approach will still work for this, there is a (probably minuscule) chance that the split verts, even though they have the same normal, may cause seams to appear in your outline. Chances are that won't happen on desktop platforms, but mobile GPUs tend to use less accurate approximations and position representations in their hardware, and it's possible, though perhaps not likely, that it could happen there. That's almost certainly not a big concern though.

    So in summary, the primary reason to not do it your way really is just because it'd result in a higher total vert count in the scene. If that's not a concern of yours, then there's no especially compelling reason not to do it that way.
     
    Xarbrough and Luke-Lamothe like this.
  11. Alexbeav

    Alexbeav

    Joined:
    Jan 15, 2017
    Posts:
    15
    This is brilliantly, mind-blowingly, amazing! Not only it's cross platform but also CROSS PLAY? I'm going to test playing against my brother on the PC while I'm on my Android phone, I have to see it to believe this!
     
  12. Gordinho

    Gordinho

    Joined:
    Feb 10, 2013
    Posts:
    4
    Hi,
    I have some questions about this template. If I go to the prefabs folder and go to the tanks folder, I drag one of the tanks to a scene but it seems that its not complete, it doesn't have movement. Shouldn't a prefab be the final thing?.
    Another question, why do people make a level, put the art work and enemies on scene and them make the player appear by code?. Whats the point?. It only makes people confused. Why not put everything on scene and make things easier to change, to custom.
    Thanks.
     
  13. AlecLarsen1989

    AlecLarsen1989

    Joined:
    Feb 7, 2017
    Posts:
    11
    Awesome. Hope you enjoy it!!!
     
  14. AlecLarsen1989

    AlecLarsen1989

    Joined:
    Feb 7, 2017
    Posts:
    11
    Some good questions.

    Prefabs are used as template objects that store common functionality. So in our case, we have three different types of tanks. These tanks share common functionality, e.g. shooting and driving. So this common functionality was placed on a prefab (CompleteTank) so that if we need to change/add to it then we do it in one place. The different tanks have different visuals so these were all stored in separate prefabs, which are then parented to the CompleteTank prefab in code.

    This brings us to the 2nd question. For this game, the player needs to be instantiated in code because it is a network game - there is no way of knowing how many players are going to be playing the game when building the scene. The second reason for instantiating the players in code is the fact that there are three different tanks (and different decorations and colors). There is no way of knowing what tank the player will use when building the scene.
     
  15. Gordinho

    Gordinho

    Joined:
    Feb 10, 2013
    Posts:
    4
    Thank you.
     
  16. Gordinho

    Gordinho

    Joined:
    Feb 10, 2013
    Posts:
    4
    Hi again,
    Sorry to trouble you again. After reading "complete tank prefab" I went to check the template and for my disappointment I couldn't find it. I came back to this post and then I read "complete tank prefab in code"
    Could I ask a big favor to Unity?. Could you put on this template or the other tanks template, a prefab of the complete tank with this sort of firing system?. I really like it and I would like to mod it and try to learn how you do it.
    If you can't put the prefab on the template, could you export as a package and make available a link in this forum?.
    Thank you again for your support and paciente.
     
  17. Acid-NN-9

    Acid-NN-9

    Joined:
    Apr 29, 2015
    Posts:
    6
    AlecLarsen1989 likes this.
  18. AlecLarsen1989

    AlecLarsen1989

    Joined:
    Feb 7, 2017
    Posts:
    11
    Hi Gordinho

    It's not a simple process of combining two prefabs because the code does set up some dependencies (because of networking and game management) but let me see if I can direct you. The best way to get an understanding of how the game is setup is to run it in editor and inspect the various game elements. Firstly, open the scene called "SplashScreen" and let's hit run. Then start a Training level (let's pick level 1). In the scene hierarchy view there is an instance of CompleteTank, as seen in the image below.
    forum1.png
    If you click on the instance of the CompleteTank and check the inspector, you will notice multiple components - scroll down until you see TankShooting, as per the screen-grab above. You will also notice the TankMovement script. These scripts have handle the control of the tank. If you scroll down further, you will see TankKeyboardInput and TankTouchInput. These scripts pass user input to the TankShooting and TankMovement scripts. The reason for this is that this game is cross platform and this is the best way to ensure code re-use.

    So I've listed some of the code that is essential to the tank control (TankShooting, TankMovement, TankKeyboardInput and TankTouchInput) so feel free to look through/modify those files. Test your changes it in the Training missions. You can also make use of your IDE (MonoDevelop or Visual Studio) and set break points in the abovementioned files and use the Debugger to see how the scripts work.
     
  19. AlecLarsen1989

    AlecLarsen1989

    Joined:
    Feb 7, 2017
    Posts:
    11
    Thanks for the kind words - we had a great team :)
     
  20. mauri_galvez

    mauri_galvez

    Joined:
    Dec 9, 2016
    Posts:
    3
    I think this project has been a great guide for me to get into creating a complete multiplayer game! At the moment I'm working on an on-rails shooter. I have been having issues when it comes to parenting the player to a network transform. It would be great if someone could give me advice on the topic. Thanks! :)
     
  21. AlecLarsen1989

    AlecLarsen1989

    Joined:
    Feb 7, 2017
    Posts:
    11
    Hi Mauri. Please give me more details about what you're struggling with and I will try to point you in the right direction :)
     
  22. orkungo

    orkungo

    Joined:
    May 3, 2014
    Posts:
    7
    Wow congrats, that is a nice state of coding. Could you please provide class diagrams to fully understand the architecture? Since my game is very close to the Tanks!!!, I would like to take the project as reference and further add asset bundles and a player database.
     
    Last edited: May 3, 2017
  23. apatton

    apatton

    Joined:
    Sep 7, 2013
    Posts:
    6
    Hi, I'm seeing a bunch of errors when I play LobbyScene and click "Create Game" or "Customize". Also no UI appears, but if I manually toggle off and on the CreateGame/Customization gameobjects at runtime then the UI shows up.

    All the errors are along the lines of:

    Trying to remove Background (UnityEngine.UI.Image) from rebuild list while we are already inside a rebuild loop. This is not supported.
    UnityEngine.Canvas:SendWillRenderCanvases()
     
  24. richard-lee

    richard-lee

    Unity Technologies

    Joined:
    Jul 14, 2015
    Posts:
    37
    Hey the docs are a bit behind but check out the following video. Talk by our network API engineer.
     
  25. orkungo

    orkungo

    Joined:
    May 3, 2014
    Posts:
    7
    Thank you Richard Lee, video is great, giving lots of information that I have been missing. Additionally to the class diagrams Alexei is talking, replay system seems great! Is it available now, I could not find much information about it?

    I would like to ask another practical question about the multiplayer feature from the Tanks!!! perspective. As a best practice to prioritise, would it be better to give a higher priority to the multiplayer feature at the beginning of the development or provide it as a later update after the development of all single player features such as achievements, AI etc. ?
     
    Last edited: May 9, 2017
  26. AlecLarsen1989

    AlecLarsen1989

    Joined:
    Feb 7, 2017
    Posts:
    11
    Hi apatton. Sorry to see that you're having issues with the project. Could you please send me more details so that we can help you resolve this? Specifically, I would like to know what version of Unity you are using, as well as your operating system and what target platform you are set to. Thanks so much :)
     
  27. richard-lee

    richard-lee

    Unity Technologies

    Joined:
    Jul 14, 2015
    Posts:
    37
    Like a lot of software development, the longer you put it off, the more you tech debt you'll have repay later. Though the tech debt seems to build up faster with networked features. It impacts how you architect code, managers, etc. The majority of customers that I've spoken to would recommend building multiplayer from the start. At the very least ,with multiplayer in mind.
     
  28. orkungo

    orkungo

    Joined:
    May 3, 2014
    Posts:
    7
    Thanks a lot :) I have it in mind also at the architecture, but seems I will re-prioritise the features and give a higher priority to multiplayer.
     
  29. apatton

    apatton

    Joined:
    Sep 7, 2013
    Posts:
    6
    64-bit Windows 10 using Unity 5.6.0f3 (64-bit) with target as PC, Mac & Linux Standalone and <DX11>

    I've recreated the project with just the tanks package, but can't get the issue to go away.

    Edit: Issue appears to be fixed in 5.6.1f1.
     
    Last edited: May 22, 2017 at 9:42 PM
  30. LLRx

    LLRx

    Joined:
    Jul 31, 2014
    Posts:
    2
    I want to change languge of game completely. But there are some problem to find language files. For example I couldn't find the Tanks description data to change tanks descriptions . Also I want to change the Single Player quests descriptions but I couldn't find the datas.
     
  31. AlecLarsen1989

    AlecLarsen1989

    Joined:
    Feb 7, 2017
    Posts:
    11
    Hi apatton

    I'm glad to see that this issue was resolved in 5.6.1f1 :). I did try to reproduce this issue on a 64 bit Windows 10 machine using Unity 5.6.0f3 (64 bit) and I could not replicate the problem you described. If you could possibly give me your complete editor log (console output) and exact steps to reproduce the problem then I could investigate it.

    Many thanks :)
     
  32. AlecLarsen1989

    AlecLarsen1989

    Joined:
    Feb 7, 2017
    Posts:
    11
    Hi LLRx

    The Tanks!!! project was not designed with localization in mind. That being said, all of the text descriptions can be found with in configuration scriptable objects. These are located in Assets/Prefabs/Configuration. The screen grab below shows the MapList configuration object. The fields are quite self-explanatory - you can change the Name and Description but avoid changing the Scene Name.

    MapList.png
     
  33. LLRx

    LLRx

    Joined:
    Jul 31, 2014
    Posts:
    2
    Thank you for answering but there is just 4 configure file. I couldn't find the other parts. I will show the parts on the pictures which I want to change :

    [​IMG]
    This is tank description in modification part

    [​IMG]

    and this is the Single Player quest part. Please help me to find these language datas