Search Unity

Official TANKS! Tutorial Q&A

Discussion in 'Community Learning & Teaching' started by willgoldstone, Sep 21, 2015.

  1. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    Hi everyone!

    We just wrapped Unite Training Day 2015 here in Boston, so I wanted to share the project with you all as soon as possible.

    UPDATE - The tutorial series is now LIVE -

    http://unity3d.com/learn/tutorials/projects/tanks-tutorial

    TANKS! is a 2 player - one keyboard project, Tank shooter.

    Controls -
    Player1 - WASD, Space to fire
    Player2 - Arrow keys, Return to fire

    Whilst we don't have the video tutorial series just yet ready to edit and add to our tutorial pages, I wanted to get the content to you and the project contains a completed version of the project with commented code you can still learn from until the footage from the day is ready. Please use this thread to give us your feedback.

    Download -

    UPDATE 2!

    After a brief bugfix, we're back on the Asset store -
    https://www.assetstore.unity3d.com/en/#!/content/46209

    Slides -

    http://bit.ly/1LGkRgC

    Note that we also have a Multiplayer version of this project which I'll post in a separate thread.

    Happy Tankin'

    Will
     
    Last edited: Oct 14, 2015
    longsl, BerniceChua, OboShape and 4 others like this.
  2. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    Imported it into Unity 5.2 and there is no main scene (although there is an empty Scenes folder).
     
  3. GFX47

    GFX47

    Joined:
    Dec 7, 2010
    Posts:
    124
    The playable scene is actually in the Complete/Scenes folder.

    There's also the input configuration missing (but I think it cannot be saved in packages).
    You have to configure the HorizontalUI, Horizontal1, Horizontal2, VerticalUI, Vertical1, Vertical2, Fire1 and Fire2 axes in Edit > ProjectSettings > Input.

    ... or simply replace your ProjectSettings/InputManager.asset file by this one ;)
    https://dl.dropboxusercontent.com/u/24322340/Unity3D/InputManager.asset
    Controls will be:
    Player 1 > move with ZQSD/WASD, fire with Left Ctrl
    Player 2 > move with Up/Down/Left/Right arrows, fire with Right Ctrl

    I also get visual artifacts and this error message with Unity 5.2.0f3, although it doesn't hurt gameplay:
    Failed setting triangles. Some indices are referencing out of bounds vertices. IndexCount: 1083, VertexCount: 29694
    UnityEditor.UnityBuildPostprocessor:OnPostprocessScene()
     
  4. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    Fantastic stuff @Will Goldstone / @GFX47
    For those of us who couldn't make it, it is great to see this content get out in to the wild
     
    theANMATOR2b and GFX47 like this.
  5. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    Hi all

    Sorry about this - the project should include the Project Settings which include input - so something went wrong with our upload to the Asset store there. We will fix this, hopefully today.

    Big thanks @GFX for spotting these inconsistencies and solving them for you all!

    Will
     
    Livederic, GFX47 and SimonDarksideJ like this.
  6. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    Updated due to asset store issues, see OP
     
    SimonDarksideJ likes this.
  7. udeb0x2k

    udeb0x2k

    Joined:
    Sep 28, 2015
    Posts:
    1
    Where is the link to the power point presentation of the Tanks game?
    Thanks
    Vince
     
  8. Mike-Geig

    Mike-Geig

    Unity Technologies

    Joined:
    Aug 16, 2013
    Posts:
    253
    Let's have a contest for "Best Whacky Tank Weapon". I want to see who can beat my spiraling death-lotus or my mega-charge blimp bomb.
     
  9. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    Added to OP - thanks!
     
  10. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    Nah @Mike Geig I'll go for the traditional worms style weapon of mass destruction, the bouncing sheep missile!
     
  11. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Hmm, does this mean the finished tutorial will only be about creating this local multiplayer tank game or will it include information about the networked version as well?

    I was 99,9% sure this project was about networked multiplayer seeing as we had the Survival Shooter last year, but guess I was wrong. :p

    I'm asking because I'm wondering if I should start reverse engineering the networked version right away or if I should wait for the tutorial series.
     
    Last edited: Oct 1, 2015
  12. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    See the opening post, it includes a link to the networked version of this tutorial as well.
     
  13. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    @SimonDarksideJ These are not the tutorials, these are the resulting projects.

    As with the Survival Shooter project I'm expecting there to be a supplementing tutorial series as well, in fact Will says this in the opening post. My question is whether this tutorial will deal solely with getting the local version of the project up and running, i.e. will it be basically the same tutorial as that in the slides or will it involve the networking part as well?

    I'm asking because the networking part is what interests me and I was sort of hoping this tutorial would serve as an introduction to the new networking, but if it isn't I'll just start on my own.
     
  14. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
  15. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    @TwiiK - So I'm currently editing a day worth of capture from Training Day - that's the 'local' version of Tanks - two players one keyboard. It's a long edit and I want to get it into a good succinct state, but I still wanted to provide the Unity content as early as possible. I'm hammering away at the edit amongst other things and will have it to you hopefully within the next couple of weeks.

    Regard Networking version - we will be writing a guide to how we ported Tanks to the networked version so that you can see the differences, this will be in article format. Currently being worked on by the team but don't have a solid ETA on it, again i'm hoping it only takes a couple of weeks.
     
    TwiiK likes this.
  16. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    Did you not see my reply at the bottom? you've 'liked' it.. but regardless let me try again -

    1. we have a video recording of training day, of the 2 player 1 keyboard version of tanks, which is what this thread is about.

    2. we have a separate networked version of tanks - link to the thread about that is in the OP. We will write article material that explains how we ported the tutorial version to this version and post it too on Learn.

    That make sense?
     
    SimonDarksideJ likes this.
  17. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Yep, I got it. I didn't realize I was meant to reply. I thought the "Like" feature was meant to be used sort of as "I've read this and I approve". :p

    I'm a bit disappointed that the tutorial isn't mainly about networked multiplayer because with just the 2 player 1 keyboard feature it feels like a smaller and simpler project than last years Survival Shooter, but I guess the Unite training day projects aren't meant to one up each other. And it's probably my own fault for having unrealistic expectations. I saw the image of the two tanks months ago and decided then and there that the project had to be about online multiplayer.

    Anyway I'm excited to check out the article and I'm sure I can get what I need from reverse engineering the networked version of the project. And for all I know the networking part of this project is tiny because it's just that easy to create an online multiplayer game with UNET.

    There's some really neat assets in there so overall I'm very happy, don't get me wrong. :)
     
  18. jpv1234

    jpv1234

    Joined:
    Dec 5, 2014
    Posts:
    89
    Awesome work! I really enjoyed assembling the project! A question, can we use the assets in our own projects?
     
  19. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    You can use our assets for whatever you wish - of course with the caveat that they are widely available assets created by unity for learning and so are widely known to be tutorial assets by a huge amount of people, so putting them into commercial projects is likely to be viewed negatively - my opinion of course ;)
     
    hippocoder and jpv1234 like this.
  20. jpv1234

    jpv1234

    Joined:
    Dec 5, 2014
    Posts:
    89
    You are right, that can be viewed negatively. I agree, however this can be awesome material while we are developing the game :)
     
  21. Daluur

    Daluur

    Joined:
    Feb 7, 2015
    Posts:
    4
    Any ETA on when the explaination for the network port will be made? or has it been, and I just cannot find it?
    ps. on the store page, you should probably link directly to the tanks tutorial and not the learn page
     
  22. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    Not yet i'm afraid, it's still in progress, but we have a lot of priorities we're working on at once right now, we'll publish the moment it's ready. Until then feel free to provide your feedback on the forum thread about that project.
     
  23. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
  24. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
  25. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    Ok, I looked but couldn't see the Unity playlist. No worries @willgoldstone

    Fantastic work getting that out!
     
  26. PedroNeves

    PedroNeves

    Joined:
    Feb 23, 2014
    Posts:
    10
    how is it to integrate an account service to give players a score per round?
    Is it hard to change the multiplayer loby to an auto matchmaking system?
     
  27. Stulaine

    Stulaine

    Joined:
    Oct 15, 2015
    Posts:
    4
    SOLVED IT. Needed to enter anchor information first.

    Quick question on the tanks tutorial. Sorry for the Noob question.

    When adding the Tex object in the message canvas it says to set the xyz and top and bottom to 0. In my view I have xyx and width and height not like the screen in the tutorial. What step did I miss?

    Thanks love the tutorial:)
     

    Attached Files:

    Last edited: Oct 18, 2015
  28. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    Hey!
    I somehow got the idea of "pimping" the TANKS! Game since i think it would be a pretty nice party game. so I basically copied the UX of Mario Kart and this is how it looks like now.
    ui_5.png

    and/or

    ui_6.png

    i know maybe a little bit to futuristic and to "holo" but that can be changed.

    the basic idea is that you can select a tank here and whoever wants to join the game, can plug in his controller, press start and yeah... join the game.
    I also want to add a "stats" screen later on so that every tank has the values like speed, stamina and a special weapon
    //edit: like this (gonna add this later to the unity-package):
    ui_stats.png


    so, since I am all for collaboration and open source, here are the UI files with pngs and the UI Unity Scene: https://www.dropbox.com/s/k12aifvll94emoa/tanks_UI.unitypackage?dl=0
    // i just saw that the bottom bar is not dynamically with the screen height but that can be changed easily

    what i would like to do now, is to find someone who is willing to collaborate and give something to the unity community.
    So, i can provide graphics but i need a dev who helps me with the implementation of the UI. and after that its done, we gonna put it on github and see what other people will do with it. what do you think?

    aaand:
    the git repository:
    https://github.com/ElKevo/TANKS
     
    Last edited: Oct 20, 2015
    BerniceChua likes this.
  29. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    Broken Pics? love to see it why not re-post?
     
  30. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Just a quick shout out...

    Just finished working through this, thoroughly enjoyed it.
    Picked up alot along the way, reinforced the concept of coroutines and putting them into practice with the game logic.
    Nice way of using the UI, and the Audio was interesting, I need to look into that a bit further.

    So, yep,enjoyed it and learned a fair bit in the process!

    Tank you Will,James and others in the Learn Team engine room behind the scenes for getting this to us, much appreciated...
    (gutted I never made it to Amsterdam tho, work got in the way :()
     
  31. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    Thanks OboShape! glad to get that feedback of someone having finished it, that's pretty much our ideal response you've given so thank you for that :)
     
  32. Mrinaank

    Mrinaank

    Joined:
    Jul 25, 2015
    Posts:
    14
    Hi, I'm still learning unity by watching tutorials. Amazing Tutorial, btw!!! I wanted to try the networking demo, so I created a new project, downloaded the networking demo, built the completed scenes. It works like a charm but there are some problems. Can anyone teach me how to solve them. I have already put it on the unity multiplayer service.

    1) I cant change the name of the game in the lobby scene. it stays as new game.
    2) After clicking on the 'List Servers' the server name is blank. How do I change that? Why is it blank?
    3) Sometimes one of the players screen doesn't show the game but shows the loading screen up to round three, but the players tank keeps moving on the other screens when the player presses the move or shoot buttons.
    4) At least one player when moving at the maximum speed, starts repeatedly acting like it is hitting a screen edge buffer everywhere. But, the other players can easily pass through those areas. Also, when the same player is moving slowly (by releasing the button every few seconds and pressing it again) the player doesn't feel the same effect it was previously feeling.

    How do I solve this? Any help is appreciated.

    Thank You in advance.


    EDIT: I've posted it on the networking demo post. You can ignore this post.
     
    Last edited: Oct 24, 2015
  33. Le_Tai

    Le_Tai

    Joined:
    Jun 20, 2014
    Posts:
    442
    I love the assets! Can I use them for commercials purpose?
     
  34. Ginz09

    Ginz09

    Joined:
    Oct 26, 2015
    Posts:
    1
    hallo..
    i'm just following your tutorial.. at the end tutorial 7 i have problem with :

    NullReferenceExpetion: Object reference not set to an instance of an object
    TankManager.Setup() (at : Assets/Scripts/Managers/TankManager.cs :27)

    i have no idea abot the problem, so i replace all scripts with complete project. but istill have same problem like that.

    can you help me soleve the problem? thanks
     
  35. Area1

    Area1

    Joined:
    Dec 13, 2014
    Posts:
    5
    Hi,

    I was wondering if there is a chance you could explain (maybe in a tutorial) how to add AI (A.I. for Artificial Intelligence ) to some enemy tanks.

    Thanks.
     
  36. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    @Area1, You'll find everything you need in these tutorials:
    https://unity3d.com/learn/tutorials/projects/survival-shooter-project
    https://unity3d.com/learn/tutorials/projects/stealth-tutorial-4x-only

    Basically:
    1. Bake a navigation mesh for your level (http://docs.unity3d.com/Manual/nav-BuildingNavMesh.html)
    2. Add a navmesh agent component to the AI tanks (http://docs.unity3d.com/Manual/nav-BuildingNavMesh.html)
    3. Create some simple logic to tell your AI tanks what to do. Look at the above tutorials for examples. The stealth tutorial contains examples of both patrol behavior and chase behavior. The survival shooter tutorial has chase behavior.
    4. Extend your AI to be as complex as you want.
     
    Last edited: Oct 27, 2015
  37. TheWabbitSeason

    TheWabbitSeason

    Joined:
    Dec 1, 2013
    Posts:
    5
    I've been playing around with the TANKS! game adding new features. My tanks take different levels of damage depending on hit location (front, sides, rear). The main cannon now needs time to recharge (5s) between shots (the green line bar above the tank) so I added a coaxial machine gun. I also added powerups (Sabot - 90 damage but requires .5s chargeup and direct hit), AP machinegun ammo, mortar support, airstrike, Chobham armor (adds Armor pool in addition to Health) and Health regen 25 or 50. The tanks move and turn slower and the HEAP round does less damage.

    Next steps are multiplayer, singleplayer with A.I., and other AI support units (infantry, IFV, etc.). I have A.I. infantry running around in prototype (blue or red blocks) but they don't do much yet.

    And the tanks smoke when damaged. Less Health = more smoke particles.

    Tanks_v1_5.jpg Tanks_damage.jpg
     
    Last edited: Oct 28, 2015
  38. Vitio

    Vitio

    Joined:
    Oct 30, 2015
    Posts:
    3
    Hi, great tutorial! Everything has worked like a charm, you explained everything very well. I have the following problem now:

    I want to extend the game to 4 players playing locally (Should be easy enough as this has been considered in all regarding functions). So I do the following:

    - create two more spawnpoints
    - adjust the GameManager GameObject in the Hierarchy panel and add 2 elements to the Tanks array
    - change the colours of the new spawnpoints and the new tanks elements to yellow and green
    - Add some input keys (Edit -> Project Settings -> Input) so the 2 new tanks can drive and shoot.

    This works great when I press the play button in Unity, but the PC x64 standalone version aswell as the Unity Web version only have two players, not four. The build seems to ignore my two additional players. I can't figure out what I'm missing, can anyone help?

    unity.png
     
    Last edited: Nov 9, 2015
  39. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    You're saying none of the builds reflect your latest changes?

    Not to be rude, but are you sure you're running the latest builds? :p

    Can you change something obvious like the title and see that change in the builds?
     
  40. Vitio

    Vitio

    Joined:
    Oct 30, 2015
    Posts:
    3
    I'm saying the builds reflect the latest changes except the addition of two additional players. I changed the Company Name, Product Name, Default Icon, Splash Image (Config Dialog Banner) and set additional input. This can be seen in the configuration window:

    unity2.png

    But when I press play:

    unity3.png


    I also tried deleting the old builds to make sure I'm running the right version.

    What could be the reason for this behaviour? Does the personal unity version only allow 2 players? Is some variable being ignored when building (perhaps the inspector Tanks array value)?

    It's also okay to be rude as long as I know what I did wrong afterwards :) I just can't find it whats missing.
     
    Last edited: Nov 9, 2015
  41. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Works perfectly well for me. You didn't include the project settings so I can't actually play it, but all 4 tanks show up in my Windows build.

    All the things you list however have nothing to do with the actual game so I would still ask you to change something that's actually visible in the build and see if it shows up. Put a cube on top of a tank or just put a cube in the game world. Anything that will let you instantly see if it's working or not. :p

    Have you tried importing your package into another project and building that? To replicate my results, I mean.
     
  42. Vitio

    Vitio

    Joined:
    Oct 30, 2015
    Posts:
    3
    I just found the problem. From the very beginning of the project, I actually ALWAYS build the complete version (The ready-for-action version supplied in case everything I do went wrong). I never even looked if I'm building the correct scene because I didn't think it would build any other than the one I'm seeing.

    unity4.png

    This is so stupid I can't even get my head around it. Of course my changes don't reflect if i'm building a scene that has nothing to do with the stuff on the screen.

    Everything is working perfectly now. Thank you very much for reminding me twice that I should check the build version >.< Daaamn.

    Thank you TwiiK :)
     
    Last edited: Nov 9, 2015
  43. kubajs

    kubajs

    Joined:
    Apr 18, 2015
    Posts:
    58
    Hi guys,
    I found the following problem in ShellExplosion class in OnTriggerEnter method:
    At the end of the method instance of the shell game object is destroyed but in reality it seems the shell instance persists to the next frame as the OnTriggerEnter is called one more time.
    Due to this fact tank takes double damage.
    I can always recreate the problem by shooting building on position 2,5, 0.22, 34.17 from the nearest possible distance (touching wall).
    I'm able to deal with this problem simply by deactivating the shell instance first but it doesn't makes me sense why the object persists to the next frame.
    I'm using unity 5.2.2f1 Personal.
    This is the position I was shooting from and the result after just one shot:
    Unity_tanks_Issue.jpg
    I cannot reproduce this problem on other positions except of this.
    I'm probably missing something but cannot figure out what's wrong here.

    Anyway thanks for the great tutorial, I learned some new techniques as usual.
    Thank you,
    Kubajs
     
  44. SunstormGT

    SunstormGT

    Joined:
    Mar 18, 2015
    Posts:
    16
    I've just completed step 2/8 and I have 1 question.

    Is it normal at the step where im at, that when my tank collides with a building or any collider its gets a force added and the tank moves in the opposite direction w/o pressing any (movement) key?
     
  45. kubajs

    kubajs

    Joined:
    Apr 18, 2015
    Posts:
    58
    @SunstormGT: I had the same problem. This only occurred when I used collider edit button in the box collider. The rigid body constantly moved without any player interaction and the tank was slowly moving sideways. I was also able to move tank by keyboard to a desired position (hardly due to the another force) but still the tank was constantly moving to the previous direction.
    In case I didn't touch the edit collider button present in the collider, I didn't have such a problem.
    Also rigidbody constraints didn't seem to work. I had frozen rotation on X and Z axis and position on Y axis and sometimes I saw tank rotating around X and Z axis.
    I suspect this might be a bug but now I'm not able to recreate the problem.

    Edit: Workaround to solve this problem should be to remove existing box collider, add new one and don't touch the edit collider button.
     
    SunstormGT likes this.
  46. GamesEngine

    GamesEngine

    Joined:
    Nov 5, 2013
    Posts:
    1
    Hi there

    Quick question for you all (hopefully someone can help) I have used my own tank model and I would like the tanks to be coloured for each player but not my tank tracks which are a separate asset to the tank body? The tracks are however a child object of the tank prefab which is giving them the colour.

    Is there another way attach the tracks without the colour?

    Thanks Tim
     
  47. SunstormGT

    SunstormGT

    Joined:
    Mar 18, 2015
    Posts:
    16
    Thx m8 that worked. Wasn't sure if it would be fixed later or was just a bug. Thx for the help!!
     
  48. kubajs

    kubajs

    Joined:
    Apr 18, 2015
    Posts:
    58
    @GamesEngine I'd also like to know details related to that. I noticed the tank model from tutorial has left and right tracks as separate child objects where each of the objects uses 2 materials (one green and another grey if I remember correctly).
    Grey for tracks, green for wheels but that's still one single object. The 2 materials are probably created automatically based on the model UV map but I don't know why only the green material's color is changed in our "change material color" for loop.
    In the code we only change color of material (not materials): meshRenderers[ii].material.color = tankManager.m_Color;
    but there is array of 2 materials in the track gameobject so I'd like to know how it internally works - maybe unity just takes the first accessible material of the gameobject (materials[0]) in this case?

    Before you get correct answer from somebody more experienced, as temporary workaround you might just ignore the particular "track" gameobjects in the for loop where you iterate the MeshRenderers.
    Something like if (meshRenderers[ii].gameObject.tag == "tankTrack") continue;

    edit: ii = i as single i is probably used for italics in this context and as side effect it also broke my whole text style here :D
     
    Last edited: Nov 5, 2015
    GamesEngine likes this.
  49. kahalany

    kahalany

    Joined:
    Jul 6, 2012
    Posts:
    80
    TanksError.png Hi, I've just finished the Tank tutorial. However when I win a round / game the UI seems to display the color hex code as a plain text rather than changing the color as seen in thee following pic. I went over my code an everything looks find. I even copied and pasted the finished code into my GameManager and TankManager. But the problem insists. When I play the completeScene included with the bundle everything works fine. Any idea what I'm doing wrong?
     
  50. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729