It's a Unity Game Dev Twofer day


Today I've got a Game Dev with Unity twofer for you...

First a Microsoft Virtual Academy on-demand series recorded from a recent live event and then a Unity powered tower defense game tutorial (with source) from Dimitris-Ilias Gkanatsios. Between the two of these you should get a nice Unity jump start indeed.

Developing 2D & 3D Games with Unity for Windows


Whether you're a beginner or an established indie game developer, if you want to ramp up your skills, join the always-entertaining Adam Tuliper (of DinoBurger fame) and a team of industry experts for this informative Jump Start. They take you on an awesome journey using Unity, one of the most popular game development tools available.

Learn how to develop Unity Games for Windows using C# and Unity, and see why Unity is the tool of choice for millions of game developers around the world. Explore the interface, 2D and 3D game development, publishing for Windows, and monetizing your games. Find out how Unity helps you animate events, use environmental controls, add finishing touches for a more polished game, and more. Don't miss it!

Full course outline:


Now that you've been through that, here's a tutorial that will walk you building a tower defense game...

A Tower Defense game in Unity Part 1, Part 2

If you’re in a hurry, you can find the complete source code on GitHub:

Unless you’ve been living in a cave in the recent years, you surely must have played a Tower Defense style game. Be it Plants vs Zombies, Kingdom Rush, geoDefense, Jelly Defense or any other, I’m sure you’ve spent much quality time setting up your defenses, killing enemies and advancing stages. So, since it’s one of the most common game types you can find on the application stores out there, I decided to try my luck and create one from scratch, using Unity3D and present it in this tutorial. Since it’s a bit bigger compared to my previous efforts, it will be split in two parts. In this first post, we’ll describe the game, the level editor, the respective XML creation and parsing and the object pool used in the game to increase performance. Check the screenshot below to get a taste of how the game looks like, running on the Unity editor.


Scenario and gameplay are both pretty basic, actually. Badgers are attacking user’s bunny house and she has her Chuck Norris trained bunnies to protect it, by shooting arrows. In order to be able to create more protector bunnies, user needs carrot money. If user kills all the badgers after the predetermined number of rounds, she wins. If enough badgers get into the bunny house, user loses! Badgers follow a path in order to approach the house upon which protector bunnies cannot be placed.

Let’s dive a bit deeper into the game mechanics and gameplay.

- Bunny House: Initial life is 10, each badger that arrives If 10 badgers arrive at the house, game is over.

- Path: The path that the badgers will walk on in order to arrive at the house. Specific waypoints will designate their direction.

- Badger: Our enemy. It has a speed property and a health component, which is decreased when it is hit by an arrow. It follows waypoints (non-visible gameobjects) that are placed on the path pieces.

- Bunny: Our defense. It can shoot arrows at a constant fire rate. It starts its activity by looking for an enemy at a close vicinity. If it finds one, it starts shooting. If the enemy dies or leaves the vicinity, it searches for another enemy. Has a standard carrot cost to create.

- Carrot: Falling randomly from the top of the screen. User needs to tap/click on them in order to increase money, to create more bunnies.

- BunnyGenerator: (yeah, I could have come up with a better name) It’s the bunny on the lower left part of the screen. User needs to drag it in order to create new bunnies. On areas that a new bunny cannot be created (such as on the path), it will highlight them as red. Upon a new bunny creation, a standard amount of money will be taken of the user’s account.

- Level Generator:  All game levels are to be stored in an XML file that uses a standard format. The Unity developer has the option to use a custom made Unity editor that saves the file from the scene editor to an XML file.

We also have a couple of “roles” that will be mentioned in this tutorial

- Unity developer: The one that will use our custom editor to create new levels for the game

- User/gamer: The end user that will enjoy our game!


Part 2

This is the second post in 2 post tutorial regarding making a tower defense in Unity. In the first post we described the game scenario and gameplay and we also mentioned the level editor, the XML file and structure that holds level information and the object pooler methodology we use. Again, if you haven’t read it, I strongly encourage you to do it ASAP, this post will be much clearer after that!

We’ll start by exploring the prefabs we have in our game.


The Discussion

  • User profile image


    When will a matching tutorial for MonoGame/XNA be prepared?

    Thank you!

    PS: XNA 5 is a top UserVoice suggestion with over 18'000+ voices:

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.