THE COOKIE NETWORK

header_01
ç Prev åNext

Creating a Gun Turret for a Game in Unity

Everybody loves that part of a game where you get to control the Big Giant Turret Gun- now it’s your turn to create that experience in Unity! Whether you are planning a Tailgunner style game, Flying Fortress, Mech Suit, Anti-Aircraft Gun, or anything else, this Citizen series has you covered.

 

What the Unity Game Engine Course Covers:

You will learn how to model, animate, texture, export, and script your turret for use in the Unity 3D game engine. Your final turret will even feature animation-synced firing, smooth-follow rotation, a custom glowing HUD, and many more features. Along the way, you will also learn many very handy game-creation skills such as custom normal maps, emmisive textures, and utilizing the Alpha Channel, optimization, animation, and more.

Once you have everything built and working, take a look at the bonus tutorials to advance your game even further!

Videos 1 – 7 are in 3D Studio Max for the building of the assets, Video 8 then begins the integration into Unity.

Software used: 3DS Max 2010, Photoshop CS5 and Unity 3.5

 

Become a Citizen Subscriber today to unlock the full series
video thumbnail
2

01 - Modeling the Turret

Download HD Video

(23:53)

video thumbnail
3

02 - Optimizing the Mesh

Download HD Video

(12:34)

video thumbnail
4

03 - UV Unwrapping

Download HD Video

(19:09)

video thumbnail
5

04 - Baking out Ambient Occlusion

Download HD Video

(10:17)

video thumbnail
6

05 - Diffuse Texture

Download HD Video

(28:23)

video thumbnail
7

06 - Create the Glass

Download HD Video

(21:45)

video thumbnail
8

07 - Normal and Specular Maps

Download HD Video

(19:59)

video thumbnail
9

08 - Unity Import and Scene Setup

Download HD Video

(18:37)

video thumbnail
10

09 - Unity Turret Movement

Download HD Video

(12:09)

video thumbnail
11

10 - Unity Turret Weapon Firing

Download HD Video

(8:43)

video thumbnail
12

11 - Unity Bonus video - Hydraulic Audio

Download HD Video

(19:09)

video thumbnail
13

12 - Unity Bonus video - Advanced Weapon Effects

Download HD Video

(14:53)

You must be logged in to upload images. Register

Discussion

35 Responses to “Course: Building and Scripting a Gun Turret for Unity 3D”
  1. Posts: 47

    Wow. I log in and “BAM!” a full on course! So Awesome!!

    #
    1
    Oct 23, 2012 at 12:16 pm
    • Enjoy! This one is really cool. Gabe does awesome stuff.

      #
      1.1
      Oct 23, 2012 at 12:24 pm
      • Posts: 47

        I’m sure I will enjoy it. I still need to figure out if a Small Intuos tablet is big enough, but I have no clue.

        #
        Oct 23, 2012 at 12:36 pm
      • Posts: 1

        i like seeing how this stuff is done…. even though im a die hard blender fanatic….. its not hard too convert if you have the knoledge

        #
        Oct 23, 2012 at 12:38 pm
    • Posts: 268

      Hope yall enjoy the new mic, too! :)

      #
      1.2
      Oct 23, 2012 at 12:46 pm
      • Posts: 47

        The sound is very clear and clean. Awesome new mic!

        #
        Oct 23, 2012 at 1:06 pm
  2. Posts: 6

    Looks very cool, new stuff to learn excellent :)

    #
    2
    Oct 23, 2012 at 4:12 pm
  3. Posts: 34

    Hi, could someone please help me out.

    when creating the sphere in blender what is the correct size for the settings.

    I have my fbx export setiings y = up and Z = forward but what is the correct setting for the scale?

    Even though I know my turret is to small I imported it into unity to test.

    I applied rotation and scale before the export.

    The test object comes into unity with rotation X -90, Y -180 and Z 0

    I am very keen to follow the tutorial, but sorry I need this little help.

    #
    3
    Oct 25, 2012 at 8:51 am
    • Posts: 34

      Oh my god im so silly, Please Please forgive me.

      FIXED

      #
      3.1
      Oct 25, 2012 at 1:40 pm
      • Posts: 268

        No problem! :D Importing to Unity can be funky…glad it worked out for you!

        #
        Oct 25, 2012 at 4:34 pm
  4. Posts: 34

    Hi Gabriel I have offically started to work on my version of the bubble turret.

    I have decided to add sheilds for the turret, please see my new image.

    I have incorp the sheilds into the glass at present this is modelled into the glass.

    Each energy section has its own material so that makes ten total stages pluss a black start up stage.

    The modifiers for the glass had to be applied in order to complete this version, but I have backups of everything.

    The glass on its own now comes in at 503 tris.

    I am new to unity but have done some tutorials so have some basic understanding.

    The thinking behind modelling the sheilds into the glass is.

    1. I do not think a gui animated texture would stay in position accurately when you would move the mouse to look for the enemy.

    The idea of the energy sections and the colours is.

    starting with green slowly moving in a gradient through the colours to red

    So the game would start up with the shields black, building up from the red to green before the game offically starts.

    As the turret gets damaged the sheilds go down to red.

    This all sounds great, but I will have to look around to get help on the best way to set this up.

    Any tips or advice you have are most welcome

    #
    4
    Oct 29, 2012 at 9:28 am
    • Posts: 268

      This is a great idea! You would simply need to perform a lerp on the mesh’s material color, I think we actually did this in the Lunar Lander series, for the fuel gauge.

      #
      4.1
      Oct 29, 2012 at 12:29 pm
  5. Designer
    Posts: 1

    Hello and thanks for this course.
    I have a question for Gabriel williams: I see that there is some scripting in the course, dose it come with the project files? Can i get the scripts already written to get them inside my project?
    If yes i will get a premium membership right now.
    I hope i will get your answer soon.

    #
    5
    Nov 2, 2012 at 1:46 am
    • Posts: 268

      You bet! Absolutely everything comes with. Sounds like you have some plans for this…care to share? It’d be great to see how these tutorials end up being used.

      #
      5.1
      Nov 2, 2012 at 1:54 am
  6. Posts: 34

    Hi sorry to trouble you.

    I have started working on the glass, but I do not know how to create the folder within the layers.

    My photoshop demo ran out so I am using photoshop elements and so far everything seems to work as per photoshop cs3.

    I wish to create the opacity folder, but do not know how :(

    #
    6
    Nov 7, 2012 at 6:12 am
    • Posts: 34

      Never mind I got a free demo of cs6 so I now have 30 days to finish my textures.

      I know photoshop is great and all that but we all can not afford to buy this :(

      Please do a tutorial with gimp as the tool.

      #
      6.1
      Nov 8, 2012 at 2:59 am
      • Posts: 268

        I would love to show it in GIMP, but but the times I tried that program, like Blender, I was frustrated, bewildered, and frightened, ha. If GIMP were smart, it would do everything possible to replicate Photoshop’s UI. Unfortunately, it does the exact opposite, and tries to do everything in a completely different manner that makes zero sense to a Photoshop veteran like myself…

        …and that’s my rant on GIMP. :D

        #
        Nov 8, 2012 at 12:34 pm
      • Posts: 34

        No problem Gabriel I understand.

        Besides wiyh so much material both here and on concept cookie photoshop is on my list some day.

        I found, I find it hard to draw a perfect straight line is there something I can do to help with this in photoshop?

        Oh it may be of intrest but everything translates perfect to CS6.

        Hopefully everthing I have learnt stays with me in regard to uv-mapping and texturing.

        I am now going somewhat slower but hopefully better.

        #
        Nov 8, 2012 at 2:07 pm
  7. Posts: 34

    Just posted a question to the help desk.

    A section of the tutorial is posing some issues.

    #
    7
    Nov 8, 2012 at 3:48 pm
    • Posts: 268

      Sorry to hear, hope we can get it figured out ASAP for you :)

      #
      7.1
      Nov 8, 2012 at 6:18 pm
      • Posts: 34

        I found an answer but had to go a different route.

        But i still fell others new to photoshop will need the help.

        One small issue. I can not be 100% sure I have pure white could you please let me what it should be.

        In relation to my issue my version is a different approach to the hud display.

        I do not wish to give to much away as the tut is for members.

        Hopefully a photoshop tutorial is in the works for begginners.

        One day I will need this,like A.S.P!

        #
        Nov 9, 2012 at 5:09 pm
    • Posts: 147

      Hi Colpolstudios, I am not sure what you mean by pure white.
      In regards to photoshop tutorials, you should check out our concept site! :)
      http://cgcookie.com/concept/
      -Alex

      #
      7.2
      Nov 9, 2012 at 6:17 pm
  8. Posts: 34

    Thanks alex for the reply and help.

    update: I have imported my version into unity and have most everything working.

    only one small issue where do I put the laser sound?

    I will have to go back and redo my target as it only shows when i move into a bright area.

    I may have chosen a slighty off colour for my white.

    #
    8
    Nov 10, 2012 at 3:46 pm
    • Posts: 34

      Update : fixed the issue with the laser sound sorry:(

      Now just to go back and watch again and hopefully fix my target emmision.

      just a side note:

      I was able to import all the materials for the shields and also a diffuse texture for the sheild itself.

      The diffuse image has the colours and I think I should NOT have the colours for the levels.

      I think I sould leave all the sections as BLACK within the diffuse texture image.

      any advice is most welcome

      #
      8.1
      Nov 10, 2012 at 4:36 pm
      • Posts: 147

        Hi Colpolstudios,
        For the shield levels you have there, what you want is to have that as a separate piece of geometry with it’s own small texture. Then you can switch out the texture depending on the energy level (have a texture for each level)
        -Alex

        #
        Nov 11, 2012 at 3:44 am
  9. Posts: 34

    update: After going back over the tutorials I have redone my glass textures.

    Fixed: new target changed position and emmison working.

    Alex I am not confident I could draw the sheild levels correctly and I am going to have a look at the luner lander in the hope I can use the lerp instead.

    I very much appricate all of the help

    Thankyou

    colpolstudios

    #
    9
    Nov 11, 2012 at 2:07 pm
  10. Posts: 34

    Just a quick question.

    Is there any way I could post my wip of my web player version?

    But each time, I right click things go kinda funky on your one???

    To be honest I am at a level under newbee when it comes to unity.

    I have not used unity for a long time and with the passing of time and learning new elements like modelling, which in itself is still a challange.

    I still have to learn about texturing and correct uv-mapping, I am somewhat overwhelmed.

    Not, withstanding all of the above,please go easy on me when I ask some obvious questions.

    #
    10
    Nov 11, 2012 at 5:18 pm
    • Posts: 268

      Hey there- sorry to be absent, glad Alex was able to help out meanwhile :)

      It sounds to me like jumping into this tutorial might be too early? It is a pretty advanced tutorial that assumes knowledge of modeling, uv unwrapping, texturing, materials, code, unity tech bits, and more.

      Have you tried going through all the “Getting Started with Unity” tutorials? They go through every little bit, down to the small details, and then the Lunar Lander and Tower Defense Tutorials add on more advanced techniques and knowledge. This will be a cinch once you’ve gone through those :)

      #
      10.1
      Nov 11, 2012 at 7:42 pm
  11. Posts: 34

    Some news update: Sheild coded and working with thanks to a unity pro friend who helped me out.

    I have been following along with “The proof of concept tutorial”, I must say this has helped me a lot as now I can shoot enemys, astroide.

    Altough this tutorial goes through all the steps I find I have a basic general question.

    I wish to use some purchased assets, however I did not model these myself and ASFAIK you can not import .fbx models into blender.

    Assuming this is correct how do i create the colliders?

    After watching again the lunar lander Gabriel you seem to have used your orignal model to create the many sections for your astroides.

    Given it is likely I will NOT be able to import the .fbx models into blender what way does one create the colliders needed for the “on collision enter”.

    I did try just using another unity collider but on each try my bullet was NOT dectected.

    In the end “The proof of concept tutorial”, allows for the use of only one mesh object which is randomly changed in size along with its collider, which may be the best, most memory saving available for a large user base.

    may I use your mesh and textures for this version if required?

    Thankyou

    #
    11
    Nov 21, 2012 at 3:05 pm
    • Posts: 34

      Sorry for all of the posts and the confusion mostly on my part :(

      I now understand the concept of appling the collider to the new object, simple error on my part.

      Without sending a bad review on the product I used, altough excellent quality, almost to big to use in gaming.

      I would maybe still like to use the textures from the “lunar lander” ok?

      We need a way to delete some posting errors, or in my case being hit over the head with the obvious!

      Sorry guys

      #
      11.1
      Nov 21, 2012 at 4:55 pm
      • Posts: 268

        No problem- of course feel free to use the assets! :)

        #
        Nov 27, 2012 at 3:26 pm
  12. Posts: 5

    The webdemo at the beginning of this tutorial http://cgcookie.com/unity/citizen-ball-turret-unity-course/
    doesn’t work in at least FF17 and IE9.

    #
    12
    Dec 16, 2012 at 12:21 pm
  13. Posts: 2

    It seems that video link for 13 is the same as 12 ! Can you fix it ? :)

    #
    13
    Dec 23, 2012 at 7:26 am
    • Posts: 147

      works fine for me, try refreshing and clearing your browser cache
      -Alex

      #
      13.1
      Dec 23, 2012 at 4:39 pm
  14. Posts: 2

    I have a question. I made a slightly different turret rig. My turret rig has 2 miniguns instead of laser cannons. I want my minigun to keep firing automatically while the mousebutton is held down. Anybody know how to code this bit in?

    #
    14
    May 11, 2013 at 4:58 pm

Leave a Comment

You must be logged in to post a comment.

Close

"Must... Watch... More... Tutorials..!"